gpt4 book ai didi

aem - CQ5 - 在选择 xtype 中动态填充选项

转载 作者:行者123 更新时间:2023-12-04 19:17:43 29 4
gpt4 key购买 nike

我已经为此苦苦思索了几个小时。我正在尝试动态填充选择 xtype 中的选项,但无法使其正常工作。这是我的 dialog.xml

<resourceType
jcr:primaryType="cq:Panel"
title="Header Type">
<items jcr:primaryType="cq:WidgetCollection">
<headerType
jcr:primaryType="cq:Widget"
fieldLabel="Header Type"
name="./headerType"
type="select"
xtype="selection">
<options jcr:primaryType="cq:WidgetCollection">
<categories
jcr:primaryType="cq:Widget"
path="/content/admin/adminView/jcr:content/header-admin-content/cats/type.infinity.json"
width="500"
xtype="cqinclude" />
</options>
</headerType>
</items>
</resourceType>

我为之生成的 json:

content/admin/adminView/jcr:content/header-admin-content/cats/type.infinity.json

看起来像这样:

{"jcr:primaryType":"nt:unstructured","item_1":  
{"jcr:primaryType":"nt:unstructured","text":"small","parameter":"small"},"item_2":
{"jcr:primaryType":"nt:unstructured","text":"medium","parameter":"medium"},"item_3":
{"jcr:primaryType":"nt:unstructured","text":"large","parameter":"large"},"item_4":
{"jcr:primaryType":"nt:unstructured","text":"none","parameter":"none"}}

当我打开对话框时没有任何反应,我只是收到一个 JS 错误 TypeError: snippet.xtype is undefined

感谢任何帮助!

最佳答案

选择 xtype 的选项可以通过两种方式动态设置

  1. 设置options属性到返回 JSON 选项数组的路径
  2. 编写一个设置选项的函数(使用 setOptions 方法)并将此函数作为 optionsProvider 的值传递属性(property)。

在这两种情况下,以 JSON 格式返回的数据都必须是一个数组。

要使用方法 1,在 headerType 节点上将 options 属性设置为将提供 JSON 数据的路径。将 optionsRoot 属性设置为包含 JSON 数组的属性的名称。将 optionsTextField 设置为 JSON 数据中应为文本的属性名称。将 optionsValueField 设置为应该作为值的 JSOn 数据中的属性名称。

有关此的详细教程可在此处找到:http://jenikya.com/blog/2013/04/dynamic-dialog-data-in-cq5.html

对于方法 2,请参阅 this

关于aem - CQ5 - 在选择 xtype 中动态填充选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27698220/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com