我依赖于从 AEM cq-dialog 获取 json 结构(或类似的东西)到渲染页面的 DOM,在那里我通过渲染页面的 JS 来获取它。
漂亮的页面模板如下所示,这里的数据标签是一个包含对话框字段的 json。如您所见,我手动输入了所有字段/属性:
<div id="myApp"
data-service="${properties.applicationService}"
data-labels="{"title":"${properties.title}","sub1":"${properties.sub1}","number":"${properties.number}"}"></div>
我更喜欢能够更动态地获取所有标签:data-labels = ${properties.labels}
我可以将 cq-dialog 中的所有“标签”属性作为一个属性获取到模板吗?
我的对话框有几个字段,如下所示,tab1 上的所有属性都被认为是“标签”属性(因此应该添加到#myApp 元素的 data-labels 属性中)。
<?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"
title="my Application"
xtype="dialog">
<items jcr:primaryType="cq:WidgetCollection">
<tabs jcr:primaryType="cq:TabPanel">
<items jcr:primaryType="cq:WidgetCollection">
<tab1
jcr:primaryType="cq:Widget"
title="Texts and Labels"
xtype="panel">
<items jcr:primaryType="cq:WidgetCollection">
<title
jcr:primaryType="cq:Widget"
fieldDescription="The title of the page."
fieldLabel="blablabla"
name="./title"
defaultValue="default value..."
xtype="textfield"/>
<sub1
jcr:primaryType="cq:Widget"
fieldDescription="First subtitle"
fieldLabel="blablba"
name="./subtitle1"
defaultValue="default value..."
xtype="textfield"/>
<number
jcr:primaryType="cq:Widget"
fieldDescription="The textfield label for number."
fieldLabel="number"
name="./number"
defaultValue="number"
xtype="textfield"/>
</items>
</tab1>
...