【问题标题】:Drop Target Issue删除目标问题
【发布时间】:2013-07-23 13:52:00
【问题描述】:

我刚刚开始使用 Adob​​e CQ5,并且正在努力推出我的第一个自定义组件...我发现了一个我无法弄清楚的错误,并希望有人能对此有所了解。

基本上,我已经定义了一个自定义图像和相关的放置区域,但不知道如何制作占位符图像。所以我这样做了:

<%
    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\" />"); }
%>

进入组件编辑对话框并单击“确定”后,它似乎可以正常工作,但是当您尝试在页面加载时放置图像而不进入对话框时,资源无法解析并且您得到一个损坏的图像图形。但是,放置目标已正确突出显示。

有什么想法吗?

【问题讨论】:

    标签: aem


    【解决方案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:dropTargets

      • leftImage { "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" }
          • rightImage { "jcr:primaryType" : "nt:unstructured", "sling:resourceType": "foundation/components/image" }
      • rightImage { "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" }
          • rightImage { "jcr:primaryType" : "nt:unstructured", "sling:resourceType": "foundation/components/image" }

    不要问我为什么会这样,它就是这样。

    【讨论】:

    • 您使用的是 CQ5 5.6.1 吗?
    猜你喜欢
    • 2020-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多