gpt4 book ai didi

javascript - 在经典对话框中选择的下拉值在触摸 UI 对话框中不会显示相同的值

转载 作者:行者123 更新时间:2023-12-03 05:23:41 25 4
gpt4 key购买 nike

我们创建了经典 UI 对话框和触摸 UI 对话框,其中包含显示动态值的下拉小部件。我们使用 optionsProvider 属性来填充经典 ui 中的这些值和触摸 ui 中的数据源。

这很好用;但是,当我们在经典 ui 中选择下拉值并在触摸 ui 模式下打开对话框后,触摸 ui 对话框不会显示经典 ui 对话框中所选的值。当我们尝试保存触摸 ui 对话框中的值并打开经典 ui 对话框时,情况也是如此。此外,无论所选值是否保存在页面的组件节点中,这些对话框在以其他对话框模式保存时都无法从保存的属性中选取值。

发生这种情况是因为监听器,因为我能够使用静态值获取其他组件中的下拉值吗?

请帮我解决这个问题。

经典 UI 属性,

<productCategory
jcr:primaryType="cq:Widget"
fieldLabel="select Product Category"
name="./productCategory"
optionsProvider="function(){ &#xa; var categories = []; &#xa; var tags = '/etc/tags/mecommerce/categories'&#xa; var url = CQ.HTTP.noCaching(tags+'.infinity.json'); &#xa; var categoriesList = CQ.HTTP.eval(url); //DAM Url&#xa; &#xa;for(var name in categoriesList){ //Looping the node structure&#xa;&#xa;/*&#xa;Each image will have the meta data in it's jcr:content. This meta data consists of many values like, its &#xa;type, size, fileFormat etc., We are checking the format is image or not and adding&#xa;*/&#x9;&#x9;&#xa; if(categoriesList[name]['jcr:title']){&#xa;&#x9;&#x9;&#x9;var list = {}; &#xa; // each option should contain text and value&#xa; list['text'] = categoriesList[name]['jcr:title']; &#xa; list['value'] = categoriesList[name]['jcr:title']; &#xa;&#x9;&#x9;&#x9;categories.push(list); &#xa; } &#xa; } &#xa; return categories; // returns the JSON&#xa;}"
type="select"
xtype="selection"/>

触摸 UI 属性,

<productCategory
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/select"
fieldLabel="select Product Category"
name="./productCategory">
<datasource
jcr:primaryType="nt:unstructured"
sling:resourceType="/apps/mecommerce/commerce/components/content/categoryStandardProductDetail/datasources/categories"
addNone="{Boolean}true"/>
</productCategory>

最佳答案

问题出在数据源上。当值添加到map时,键和值不一样。更正后问题得到解决。

 List<KeyValue> categories = new ArrayList<KeyValue>();

for (Iterator<Resource> it = categoryRes.listChildren(); it.hasNext();) {
Resource category = it.next();
ValueMap vm = ResourceUtil.getValueMap(category);

String title = vm.get("jcr:title", category.getName());

String value = vm.get("jcr:title", category.getName());
if (!title.equals("*")) {
value = value;
}

categories.add(new KeyValue(category.getName(), value));
}

修改为,

List<KeyValue> categories = new ArrayList<KeyValue>();

if (dsCfg.get("addNone", false)) {
categories.add(new KeyValue("", ""));
}

for (Iterator<Resource> it = categoryRes.listChildren(); it.hasNext();) {
Resource category = it.next();
ValueMap vm = ResourceUtil.getValueMap(category);

String title = vm.get("jcr:title", category.getName());

String value = vm.get("jcr:title", category.getName());
if (!title.equals("*")) {
value = value;
}

categories.add(new KeyValue(value, value));
}

关于javascript - 在经典对话框中选择的下拉值在触摸 UI 对话框中不会显示相同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41255582/

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