2013-07-23 58 views
1

我刚开始使用Adobe 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\" />"); } 
%> 

它似乎正常工作,一旦你已经走了到组件编辑对话框,并点击“确定”,但是当你试图删除的页面加载图像,而不必去到对话框资源不能解析,并且您会看到一个破碎的图像图形。尽管放置目标正确突出显示。

任何想法?

回答

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:dropTargets CRXDE Lite节点中,您需要为每个图像,一个子参数节点以及组件中所有可用图像的子节点创建一个主节点。

因此,举例来说,如果你有一个leftImage和右图,它应该是这样的(解释JSON作为一个小产权地图):

  • CQ:dropTargets

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

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

不要问我为什么它的作品,它只是。

+0

您使用CQ5 5.6.1吗? – Alvin

+4

上帝帮助我们 – Chris