将选择下拉列表添加到对话框窗口

jus*_*der 10 aem

我在如何为选择对话框添加选项方面遇到了困难.

我正在阅读的Adobe笔记在这里:CQ.form.Selection

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

[
    {
        value: "pink", // all types except "combobox"
        text: "Pink",
        qtip: "Real Pink" // "select" and "combobox"
    }
]
Run Code Online (Sandbox Code Playgroud)

但是,CRXDE Lite不允许我在添加新属性时选择或键入Object,这是我不知所措的地方.还有另一种输入复杂价值的方法吗?

ano*_*ave 20

添加选项Object[]将通过子节点而不是属性来完成.(事实上​​,无论你Object在API中看到哪一个,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>
Run Code Online (Sandbox Code Playgroud)

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

  1. 右键单击选择节点,然后选择" 创建" >" 节点".
  2. 给这个节点jcr:primaryTypecq:WidgetCollection.这将保留您的选项值.
  3. 各个选项现在可以添加为这个孩子节点,用jcr:primaryTypent:unstructured.
  4. 请将您的属性(value,text,qtip)这些子节点上.

  • 快速提示:要将下拉列表更改为单选按钮,请在selectList中将`type ="select"`更改为`type ="text"`. (3认同)