1

I've just started using Adobe CQ5 and am working my way through getting my first custom components rolled... I've found a bug that I can't figure out and was hoping someone could shed some light on it.

Basically, I've defined a custom image and associated drop area, but couldn't figure out how to do a placeholder image. So I did this:

<%
    if (leftImage != null && leftImage.hasContent()) { leftImage.draw(out); }
    else { leftImage.setSelector(".img"); out.print("<img class=\"" + DropTarget.CSS_CLASS_PREFIX + "panelLeftImage" + "\" src=\"http://placehold.it/300x300\" />"); }
%>

It seems to work properly once you've gone into the component edit dialog and clicked "OK", but when you try to drop an image at page load without having gone into the dialog, the resource doesn't resolve and you get a broken image graphic. The drop target is correctly highlighted though.

Any ideas?

4

1 回答 1

1

对于下一个任性的旅行者......我最终能够解决这个问题。

我的 JSP 现在看起来更像这样:

<%
    Image leftImage = new Image(resource, "panelLeftImage");
    leftImage.addCssClass(DropTarget.CSS_CLASS_PREFIX + "panelLeftImage");
    leftImage.setSelector(".img");
    leftImage.setDoctype(Doctype.fromRequest(request));

    if (leftImage != null && leftImage.hasContent()) { leftImage.draw(out); }
    else { out.print("<img class=\"" + DropTarget.CSS_CLASS_PREFIX + "panelLeftImage" + "\" src=\"http://placehold.it/460x200\" />"); }
%>

为您在对话框中创建的每个图像面板冲洗并使用不同的名称重复。

cq:dropTargetsCRXDE Lite 节点中,您需要为每个图像创建一个主节点,一个子参数节点,然后是组件中所有可用图像的子节点。

例如,如果你有一个 leftImage 和 rightImage,它看起来像这样(将 JSON 解释为一个小属性映射):

  • cq:drop 目标

    • 左图 { "accept": "image.*", "groups": "media", "jcr:primaryType": "cq:DropTargetConfig", "propertyName": "./leftImage/fileReference" }

      • 参数 { "jcr:primaryType" : "nt:unstructured", "sling:resourceType": "pathToYourComponent" }
        • 左图 { "jcr:primaryType" : "nt:unstructured", "sling:resourceType": "foundation/components/image" }
        • 右图 { "jcr:primaryType" : "nt:unstructured", "sling:resourceType": "foundation/components/image" }
    • 右图 { "accept": "image.*", "groups": "media", "jcr:primaryType": "cq:DropTargetConfig", "propertyName": "./rightImage/fileReference" }

      • 参数 { "jcr:primaryType" : "nt:unstructured", "sling:resourceType": "pathToYourComponent" }
        • 左图 { "jcr:primaryType" : "nt:unstructured", "sling:resourceType": "foundation/components/image" }
        • 右图 { "jcr:primaryType" : "nt:unstructured", "sling:resourceType": "foundation/components/image" }

不要问我为什么有效,它就是有效。

于 2013-07-24T14:22:31.027 回答