如何防止cq:dialog继承

11

我正在将经典的UI对话框迁移到触摸UI对话框,我已经迁移了父级组件对话框,在观察中发现AEM在子组件中也显示了父级对话框的选项卡和属性。在现有的经典UI对话框中,它不会继承父级属性,而在触摸UI中会。

我们如何通过防止对话框继承来实现与经典UI相同的行为?

如果有人了解此问题,请分享详细信息。

4个回答

20

您可以使用 sling:hideChildren 属性来隐藏继承的选项卡和属性。例如,假设您想要隐藏继承的 permissionscloudservices 选项卡,并自定义 basicadvanced 选项卡:

...
<items jcr:primaryType="nt:unstructured">
    <tabs
        ...>
        <layout
            .../>
        <items
            jcr:primaryType="nt:unstructured"
            sling:hideChildren="[permissions,cloudservices]">
            <basic
                .../>
            <advanced
                .../>
        </items>
    </tabs>
</items>
...

谢谢Bruce,这个配置解决了应用程序中的继承问题。非常感谢你帮助解决这个问题。 - Sandeep Rawat
嗨,Bruce,实施上述配置后,sling:hideChildren正在隐藏其下的所有子节点,并且在子组件中也是如此。但是这样做,它也会隐藏自己的所有子节点。这只解决了一部分问题,但问题仍然存在。 - Sandeep Rawat
我已经在每个组件中使用sling:hideChildren本身来解决它,所以这需要一些工作,但这解决了我面临的问题。我仍然想知道是否有任何全局设置可以做到这一点。 - Sandeep Rawat
这种行为在AEM 6.0和AEM 6.1中有所不同吗?在6.0中,如果我删除组件中的属性,则该属性会消失,但在6.1中,该属性仍然会出现...为什么?是否有文档记录了这种变化? - Phoenix_uy

11
您可以在此处找到有关AEM文档中的Sling资源合并。具体查看有关资源合并属性以及如何操纵不同属性的文档。
资源合并器提供以下属性: - sling:hideProperties (String或String[]) 指定要隐藏的属性或属性列表。通配符*可隐藏全部。 - sling:hideResource (Boolean) 指示是否应完全隐藏资源,包括其子级。 - sling:hideChildren (String或String[]) 包含要隐藏的子节点或子节点列表。节点的属性将被维护。通配符*可隐藏全部。 - sling:orderBefore (String) 包含当前节点应位于其前面的同级节点的名称。
这些属性影响覆盖/重写(通常在/apps)中使用相应/原始资源/属性(来自/libs)。

谢谢Ben,这个配置可以完成,就像Bruce在上面的帖子中建议的那样。感谢你帮我找到解决办法。 - Sandeep Rawat

3

sling:hideChildren属性添加到子组件的对话框中。

您可以将此属性添加到特定字段集/选项卡/字段的直接父级中,以隐藏它们。

语法:

属性名称:sling:hideChildren

属性类型:String或String[]

属性值:立即子元素的名称,“*”表示隐藏所有子元素

示例:

要隐藏以下对话框的属性选项卡下的所有字段:

<content
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/coral/foundation/container">
    <items jcr:primaryType="nt:unstructured">
        <fixedcolums
            jcr:primaryType="nt:unstructured"
            sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns">
            <items jcr:primaryType="nt:unstructured">
                <properties
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="granite/ui/components/coral/foundation/container">
                    <items jcr:primaryType="nt:unstructured">
                        <startLevel
                            jcr:primaryType="nt:unstructured"
                            sling:resourceType="granite/ui/components/coral/foundation/form/numberfield"
                            ../>
                        <showHidden
                            jcr:primaryType="nt:unstructured"
                            sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
                            ../>
                    </items>
                </properties>
            </items>
        </fixedcolums>
    </items>
</content>

将sling:hideChildren属性添加到其直接父节点items中(请参见下文)。
<content
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/coral/foundation/container">
    <items jcr:primaryType="nt:unstructured">
        <fixedcolums
            jcr:primaryType="nt:unstructured"
            sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns">
            <items jcr:primaryType="nt:unstructured"
                sling:hideChildren="*">
                <properties
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="granite/ui/components/coral/foundation/container">
                    <items jcr:primaryType="nt:unstructured">
                        <startLevel
                            jcr:primaryType="nt:unstructured"
                            sling:resourceType="granite/ui/components/coral/foundation/form/numberfield"
                            ../>
                        <showHidden
                            jcr:primaryType="nt:unstructured"
                            sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
                            ../>
                    </items>
                </properties>
            </items>
        </fixedcolums>
    </items>
</content>

如果只想隐藏startLevel字段,可以在它的直接父节点上添加sling:hideChildren属性(见下方代码)

<content
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/coral/foundation/container">
    <items jcr:primaryType="nt:unstructured">
        <fixedcolums
            jcr:primaryType="nt:unstructured"
            sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns">
            <items jcr:primaryType="nt:unstructured">
                <properties
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="granite/ui/components/coral/foundation/container">
                    <items jcr:primaryType="nt:unstructured"
                        sling:hideChildren="startLevel">
                        <startLevel
                            jcr:primaryType="nt:unstructured"
                            sling:resourceType="granite/ui/components/coral/foundation/form/numberfield"
                            ../>
                        <showHidden
                            jcr:primaryType="nt:unstructured"
                            sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
                            ../>
                    </items>
                </properties>
            </items>
        </fixedcolums>
    </items>
</content>

1

虽然这个链接可能回答了问题,但最好在此处包含答案的基本部分并提供参考链接。如果链接页面更改,仅有链接的答案可能会失效。 - slfan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接