我正在尝试添加 cq:listener
https://docs.adobe.com/docs/en/cq/5-5/developing/components/edit_config.html#cq:listeners到我的组件,以便在选择 Assets 并单击“确定”后,页面会刷新。
这就是组件在我选择 Assets 并单击“确定”的屏幕上的样子。
在我的代码中,dialog.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"
jcr:primaryType="cq:Dialog"
xtype="dialog">
<items
jcr:primaryType="cq:Widget"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
<tab1
jcr:primaryType="cq:Panel"
title="Tab">
<items
jcr:primaryType="cq:WidgetCollection">
<asset-reference
jcr:primaryType="cq:Widget"
fieldLabel="Foo Bar:"
fieldDescription="Select the asset under /content/dam/foo-sync"
name="./fileReference"
xtype="pathfield"
rootPath="/content/dam/evernote-sync"/>
</items>
</tab1>
</items>
</items>
</jcr:root>
_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" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:EditConfig">
<cq:dropTargets jcr:primaryType="nt:unstructured">
<fileReference
jcr:primaryType="cq:DropTargetConfig"
accept="[text/.*]"
groups="[media]"
propertyName="./fileReference"/>
</cq:dropTargets>
</jcr:root>
最佳答案
创建一个名称为 cq:listeners
的节点,并键入 cq:EditListenersConfig
作为 cq:EditConfig
节点的子节点。将属性 afteredit
添加到新创建的值为 REFRESH_PAGE
的节点,以便在编辑组件后刷新页面。默认情况下,此值为 REFRESH_SELF
,因此只有组件在编辑后刷新,而不是整个页面。
_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" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:EditConfig">
<cq:listeners jcr:primaryType="cq:EditListenersConfig"
afteredit="REFRESH_PAGE"/>
<cq:dropTargets jcr:primaryType="nt:unstructured">
<fileReference
jcr:primaryType="cq:DropTargetConfig"
accept="[text/.*]"
groups="[media]"
propertyName="./fileReference"/>
</cq:dropTargets>
</jcr:root>
更多详细信息可以在 link mentioned in the question 中找到本身。
关于osgi - 如何添加cq :listener to a component,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31128262/