>我正在尝试向对话框(花岗岩/珊瑚UI(添加一个单选按钮。该按钮可以在节点中存储值。但是当对话框再次打开时,它不会使用存储的值进行初始化。我还有一个经典的UI对话框。当通过它编辑值并重新打开对话框时,它将被初始化。当通过触摸UI编辑值时,对话框是经典UI不读取存储在节点中的值。我在对话框中有一个文本字段,无论使用何种 UI,它都可以正常工作。
两个对话框中使用的名称相同。
触摸 UI 节点的 JSON:
{
"jcr:primaryType":"nt:unstructured",
"jcr:title":"Field Set Title as Field label for button group",
"sling:resourceType":"granite/ui/components/foundation/form/fieldset",
"items":{
"jcr:primaryType":"nt:unstructured",
"charset":{
"jcr:primaryType":"nt:unstructured",
"name":"_charset_",
"value":"utf-8",
"ignoreData":true,
"sling:resourceType":"granite/ui/components/foundation/form/hidden"
},
"Button1":{
"jcr:primaryType":"nt:unstructured",
"name":"./radioButton",
"text":"button 1",
"value":"button 1",
"checked":true,
"sling:resourceType":"granite/ui/components/foundation/form/radio"
},
"Button2":{
"jcr:primaryType":"nt:unstructured",
"name":"./radioButton",
"text":"button 2",
"value":"button 2",
"sling:resourceType":"granite/ui/components/foundation/form/radio"
}
}
}
经典 UI 的 JSON :
{
"jcr:primaryType":"cq:Panel",
"title":"Tab 1",
"items":{
"jcr:primaryType":"cq:WidgetCollection",
"sampleText":{
"jcr:primaryType":"nt:unstructured",
"name":"./sampleText",
"xtype":"textfield",
"fieldLabel":"sample text"
},
"radioButton":{
"jcr:primaryType":"cq:Widget",
"name":"./radioButton",
"type":"radio",
"xtype":"selection",
"fieldLabel":"Radio Button",
"options":{
"jcr:primaryType":"cq:WidgetCollection",
"button 1":{
"jcr:primaryType":"nt:unstructured",
"text":"Button 1",
"value":"Button 1"
},
"button 2":{
"jcr:primaryType":"nt:unstructured",
"text":"Button 2",
"value":"Button 2"
}
}
}
}
}
您需要将无线电场放在无线电组中。资源类型为"花岗岩/ui/组件/基础/表单/无线电组"。
例:
+ myradiogroup
- sling:resourceType = "granite/ui/components/foundation/form/radiogroup"
+ items
+ option1
- sling:resourceType = "granite/ui/components/foundation/form/radio"
- name = "browser"
- value = "ie"
- text = "Internet Explorer"
+ option2
- sling:resourceType = "granite/ui/components/foundation/form/radio"
- name = "browser"
- value = "chrome"
- text = "Chrome"
+ option3
- sling:resourceType = "granite/ui/components/foundation/form/radio"
- name = "browser"
- value = "firefox"
- text = "Firefox"