向对话框窗口添加下拉选择框

10

我在尝试为对话框添加选项时遇到了困难。

我正在阅读的 Adobe 文档在这里:CQ.form.Selection

向下滚动到 options : Object[]/String 将显示两种引用选项以提供所需选择的方法,即通过对象或字符串。我正在尝试使用对象方法。他们提供的格式示例已经足够好了。

[
    {
        value: "pink", // all types except "combobox"
        text: "Pink",
        qtip: "Real Pink" // "select" and "combobox"
    }
]

然而,CRXDE Lite不允许我在添加新属性时选择或输入“Object”,这就是我困惑的地方。是否有其他方法输入复杂值?

1个回答

21

将选项作为Object[]添加应通过一个子节点完成,而不是属性。(实际上,在API中看到任何Object时,请将其视为node而不是property。)

在您的dialog.xml文件中,可以按如下方式完成:

<selectList
    jcr:primaryType="cq:Widget"
    defaultValue="0"
    fieldLabel="Number"
    name="./number"
    type="select"
    xtype="selection">
    <options jcr:primaryType="cq:WidgetCollection">
        <one
            jcr:primaryType="nt:unstructured"
            text="One"
            value="1"/>
        <two
            jcr:primaryType="nt:unstructured"
            text="Two"
            value="2"/>
        <three
            jcr:primaryType="nt:unstructured"
            text="Three"
            value="3"/>
        <four
            jcr:primaryType="nt:unstructured"
            text="Four"
            value="4"/>
    </options>
</selectList>

在CRXDE中,可以通过创建相同的层次结构来实现:

  1. 右键单击您的选择节点,然后选择创建 > 节点
  2. 将此节点的jcr:primaryType设置为cq:WidgetCollection。这将保存您的选项值。
  3. 现在,可以将各个选项作为其子节点添加到其中,并使用jcr:primaryType设置为nt:unstructured
  4. 将属性(valuetextqtip)放置在这些子节点上。

3
快速提示:如果要将下拉列表更改为单选按钮,在selectList中,您需要将type="select"更改为type="text" - justacoder

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