cq:emptyText在Adobe CQ5.5中不起作用

时间:2013-10-07 20:03:01

标签: adobe components containers cq5

我正在开发Adobe CQ5.5中的自定义容器组件,我希望将自定义消息作为占位符而不是默认的“在此处拖动组件或资源”。

我到目前为止发现的是我必须添加cq:emptyText =“我的自定义占位符消息”。可能我错过了一些东西,因为这个属性被完全忽略了。这是我的组件的文件夹structrure:

  • [clientlib]
  • .content.xml
  • _cq_editConfig.xml
  • dialog.xml
  • myContainer.jsp

根据Adobe's official tutorialsthis wonderful tutorial for building an Accordion container,cq:emptyText应该进入_cq_editConfig.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    cq:actions="[edit]"
    cq:dialogMode="floating"
    cq:emptyText="Drag My Custom components here"
    jcr:primaryType="cq:EditConfig">
    <cq:listeners
        jcr:primaryType="cq:EditListenersConfig"
        afteredit="REFRESH_PAGE"/>
</jcr:root>

不幸的是,即使包含cq:emptyText,我仍然会看到默认的占位符文本。

任何帮助都将受到高度赞赏!

谢谢!

斯坦。


更新

在Tomek的建议之后,我仍然得到“拖动组件或资源”而不是我的自定义消息,因此我仍在寻找答案。我的组件的文件结构现在看起来像这样: - [clientlib] - [新] ---- .content.xml ---- _cq_editConfig.xml - .content.xml - _cq_editConfig.xml - dialog.xml - tabContainer.jsp

.content.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    cq:isContainer="{Boolean}true"
    jcr:primaryType="cq:Component"
    jcr:title="Tab Container"
    jcr:description="Container component for tab pages"
    sling:resourceSuperType="foundation/components/parsys"
    componentGroup="MyComponents"/>

_cq_editConfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    cq:actions="[edit]"
    cq:dialogMode="floating"
    jcr:primaryType="cq:EditConfig">
    <cq:listeners
        jcr:primaryType="cq:EditListenersConfig"
        afteredit="REFRESH_PAGE"/>
</jcr:root>

新/ .content.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="cq:Component"
    jcr:title="New Paragraph"
    sling:resourceType="foundation/components/parsys/new"
    componentGroup=".hidden"/>

新/ _cq_editConfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    cq:actions="[_clear,insert]"
    cq:emptyText="Drag My Custom components here"
    jcr:primaryType="cq:EditConfig" />

2 个答案:

答案 0 :(得分:4)

当您正在实施parsys时,您需要以下结构,如TomekRękawek所建议的那样:

.content.xml 此处的重要部分是resourceSuperType

<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    cq:isContainer="{Boolean}true"
    jcr:primaryType="cq:Component"
    jcr:title="Your title"
    sling:resourceSuperType="foundation/components/parsys" />

新/ .content.xml

<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="cq:Component"
    jcr:title="New Paragraph"
    sling:resourceType="foundation/components/parsys/new"
    componentGroup=".hidden"/>

new / _cq_editConfig.xml 这是您要设置cq:emptyText属性的地方)

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    cq:actions="[_clear,insert]"
    cq:emptyText="Drag My Custom components here"
    jcr:primaryType="cq:EditConfig"/>

此时我没有在组件占位符上获得“在此处拖动我的自定义组件”文本。对我来说,诀窍是用以下内容创建new/new.jsp

新/ new.jsp

<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"
%><%@include file="/libs/foundation/global.jsp"
%><%@ page session="false" import="
    com.day.cq.wcm.api.components.EditContext" %><%

    editContext.getEditConfig().setEmpty(true);
%>

然后我能够看到我在new/_cq_editConfig.xml中设置的空白文本。我在CQ5.6上测试了这个。

希望这有帮助。

答案 1 :(得分:2)

此容器通常称为段落系统 parsys 。你应该有这样的结构:

<强> .content.xml

<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    cq:isContainer="{Boolean}true"
    jcr:primaryType="cq:Component"
    jcr:title="Your title"
    sling:resourceSuperType="foundation/components/parsys" />

新/ .content.xml

<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="cq:Component"
    jcr:title="New Paragraph"
    sling:resourceType="foundation/components/parsys/new"
    componentGroup=".hidden"/>

新/ _cq_editConfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    cq:actions="[_clear,insert]"
    cq:emptyText="Drag My Custom components here"
    jcr:primaryType="cq:EditConfig"/>

因此,您需要为组件创建new子目录,并且应将该属性添加到文件new/_cq_editConfig.xml