java - AEM 将新选项卡添加到 OOTB 页面组件触摸 UI 对话框的对话框

标签 java xml aem aem-touch-ui

我想向 OOTB 页面组件触摸 UI 对话框 (/libs/foundation/components/page) 添加一个新选项卡,以便从该 OOTB 组件继承的所有页面都将具有这些字段.

不幸的是,这不是一个仅将选项卡添加到每个模板组件的选项,因为我正在构建一个插件而不是一个实现。

我一直在尝试覆盖 /libs/foundation/components/page/_cq_dialog/content/items/tabs/items/ 并仅将我的选项卡添加到该叶 items 节点,但它不会拉出其余的 OOTB 选项卡。我认为这是因为它不是叶节点,并且在进行覆盖时它希望是叶节点。因此,我需要以某种方式将我定义的内容与 OOTB 触摸 ui 对话框合并。

这是我的 /apps/foundation/components/page/_cq_dialog 节点:

<?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"
          xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
          jcr:primaryType="nt:unstructured"
          jcr:title="Page"
          sling:resourceType="cq/gui/components/authoring/dialog"
          extraClientlibs="[cq.common.wcm,cq.siteadmin.admin.properties]"
          mode="edit">
    <content
            jcr:primaryType="nt:unstructured"
            sling:resourceType="granite/ui/components/foundation/container"
            class="cq-dialog-content-page">
        <items jcr:primaryType="nt:unstructured">
            <tabs
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="granite/ui/components/foundation/container"
                    rel="cq-siteadmin-admin-properties-tabs">
                <layout
                        jcr:primaryType="nt:unstructured"
                        sling:resourceType="granite/ui/components/foundation/layouts/tabs"
                        type="nav"/>
                <items jcr:primaryType="nt:unstructured">
                    <custom
                            jcr:primaryType="nt:unstructured"
                            jcr:title="Custom"
                            sling:resourceType="granite/ui/components/foundation/section">
                        <layout
                                jcr:primaryType="nt:unstructured"
                                sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"
                                margin="{Boolean}false"/>
                        <items jcr:primaryType="nt:unstructured">
                            <column
                                    jcr:primaryType="nt:unstructured"
                                    sling:resourceType="granite/ui/components/foundation/container">
                                <items jcr:primaryType="nt:unstructured">
                                    <customsection
                                            jcr:primaryType="nt:unstructured"
                                            jcr:title="Custom field"
                                            sling:resourceType="granite/ui/components/foundation/form/fieldset">
                                        <items jcr:primaryType="nt:unstructured">
                                            <customfield
                                                    jcr:primaryType="nt:unstructured"
                                                    sling:resourceType="granite/ui/components/foundation/form/textfield"
                                                    fieldLabel="custom field"
                                                    name="customField"/>
                                        </items>
                                    </customsection>
                                </items>
                            </column>
                        </items>
                    </custom>
                </items>
            </tabs>
        </items>
    </content>
</jcr:root>

谢谢!

最佳答案

您看不到基础页面组件中其余选项卡的原因是您是overlayingitems所有选项卡的节点。当您覆盖时,您正在重新定义 libs 的功能组件并优先考虑覆盖的组件。如果您还想拥有其余选项卡,则必须将它们全部复制到覆盖组件中,强烈不建议这样做,因为您将无法升级组件当您升级 AEM 或安装服务包时。

我会推荐extending通过设置值 sling:resourceType 来代替组件至foundation/components/page在您网站的基本页面组件中。这样,您就可以添加额外的自定义选项卡,并从 libs 继承其余部分。 。很有可能(如果遵循 aem 最佳实践),您的站点已经有一个具有此属性的基页组件,并且其余模板将从此组件继承。添加以下_cq_dialog到该页面组件,您应该会在所有页面上看到新选项卡。

.content.xml of your base page component. One of the main templates from /apps/<<prj>>/templates will have a sling:resourceType linking to this page component.

<?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="Base Page Component"
    sling:resourceSuperType="foundation/components/page"
    componentGroup=".hidden"/>

_cq_dialog - reusing your code except for a new prop - sling:orderBefore="cloudservices", to order your new tab

<?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" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
          jcr:primaryType="nt:unstructured">
    <content jcr:primaryType="nt:unstructured">
        <items jcr:primaryType="nt:unstructured">
            <tabs jcr:primaryType="nt:unstructured">
                <items jcr:primaryType="nt:unstructured">
                    <custom
                        jcr:primaryType="nt:unstructured"
                        jcr:title="Custom"
                        sling:orderBefore="cloudservices"
                        sling:resourceType="granite/ui/components/foundation/section">
                        <layout
                            jcr:primaryType="nt:unstructured"
                            sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"
                            margin="{Boolean}false"/>
                        <items jcr:primaryType="nt:unstructured">
                            <column
                                jcr:primaryType="nt:unstructured"
                                sling:resourceType="granite/ui/components/foundation/container">
                                <items jcr:primaryType="nt:unstructured">
                                    <customsection
                                        jcr:primaryType="nt:unstructured"
                                        jcr:title="Custom field"
                                        sling:resourceType="granite/ui/components/foundation/form/fieldset">
                                        <items jcr:primaryType="nt:unstructured">
                                            <customfield
                                                jcr:primaryType="nt:unstructured"
                                                sling:resourceType="granite/ui/components/foundation/form/textfield"
                                                fieldLabel="custom field"
                                                name="customField"/>
                                        </items>
                                    </customsection>
                                </items>
                            </column>
                        </items>
                    </custom>
                </items>
            </tabs>
        </items>
    </content>
</jcr:root>

Screenshot

enter image description here

有关组件层次结构和继承的更多信息 here

关于java - AEM 将新选项卡添加到 OOTB 页面组件触摸 UI 对话框的对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52066743/

相关文章:

java - 等待 JTextField "SPACE"事件

php - Mysql连接表数据,需要在1个查询中从两者中拖出数据

c# - 在控制生成的 XML 元素的同时对派生类使用 C# xmlserializer

java - 在java中的链接 HashMap 中查找特定键的值

aem - 吊索网址中后缀的用途是什么

java - 使网站适应iphone

java - NewDirectByteBuffer 是否在 native 代码中创建拷贝

android - 如何使用相应的 XML 文件创建 Activity ,只需点击一个按钮

页面属性中的 AEM 页面图像不应用吊索 :resourceType

java - 在 javac 中强制执行包声明检查