osgi - 如何添加cq :listener to a component

标签 osgi aem

我正在尝试添加 cq:listener https://docs.adobe.com/docs/en/cq/5-5/developing/components/edit_config.html#cq:listeners到我的组件,以便在选择 Assets 并单击“确定”后,页面会刷新。

这就是组件在我选择 Assets 并单击“确定”的屏幕上的样子。

enter image description here

在我的代码中,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/

相关文章:

java - 访问其他osgi包中的静态资源?

maven - 带有 maven-bundle-plugin 的 OSGI JAR 包

xml - 是否可以在触摸 UI 对话框中包含文件?

java - 如果目标目的地的父级尚不存在,如何将页面复制到给定路径?

OSGi Web 应用程序教程

java - 无法获取状态更改锁

osgi - 如何在 apache felix gogo shell 中自定义 OSGi 提示符

java - 如何在 CQ5 Archetype Maven 项目中引入自动完成功能并使 Eclipse 识别 CQ 类,如 Sling Repository、javax.jcr.Node 等?

java - Adobe 体验管理器 6.2

javascript - 在html页面中使用sightly使用&lt;script&gt;