I am having a touch UI component for which I am creating a dialog in AEM 6. I have a requirement to create 2 radio buttons in the touch dialog and if either one of them are selected, the corresponding value of the selected radio button should be displayed. however, I am not understanding how to create the radio button options. I have implemented the same in classic dialog where the xtype=selection and type=radiogroup is used, but I do not understand how to create it in touch dialog

- 28,968
- 18
- 162
- 169

- 1,561
- 5
- 27
- 42
-
I think its not same as in classic ui. you may have look on it /libs/foundation/components/form/radio component – Vivek Dhiman Dec 17 '14 at 11:46
4 Answers
Here is a radio group example for CoralUI v1/v2. The radiogroup
is optional, the radio
widgets on their own will still work. The group is only needed if you want to have a label for the group.
<radioGroup jcr:primaryType="nt:unstructured"
name="./type"
text="Fruit"
required="{Boolean}true"
sling:resourceType="granite/ui/components/foundation/form/radiogroup"
renderReadOnly="{Boolean}true">
<items jcr:primaryType="nt:unstructured">
<radioApple jcr:primaryType="nt:unstructured"
name="./fruit"
text="Apple"
value="apple"
cq-msm-lockable="fruit"
sling:resourceType="granite/ui/components/foundation/form/radio"
renderReadOnly="{Boolean}true"/>
<radioPear jcr:primaryType="nt:unstructured"
name="./fruit"
text="Pear"
value="pear"
cq-msm-lockable="fruit"
sling:resourceType="granite/ui/components/foundation/form/radio"
renderReadOnly="{Boolean}true"/>
<radioDefaultValue jcr:primaryType="nt:unstructured"
name="./fruit@DefaultValue"
value="apple"
sling:resourceType="granite/ui/components/foundation/form/hidden"/>
<radioDefaultWhenMissing jcr:primaryType="nt:unstructured"
name="./fruit@UseDefaultWhenMissing"
value="true"
sling:resourceType="granite/ui/components/foundation/form/hidden"/>
</items>
</radioGroup>
NOTE: If you need a default value to be set before you even open the dialog, then you'll need to define it in the template (if it is a page dialog) or for the component.
For a component, to set the default value to apple
you would add this in the .content.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:Component"
jcr:title="Fruit Component"
componentGroup="My App Group"
sling:resourceSuperType="foundation/components/parbase">
<cq:template jcr:primaryType="nt:unstructured" fruit="apple"/>
</jcr:root>
See also:
- http://docs.adobe.com/docs/en/aem/6-0/develop/ref/granite-ui/api/jcr_root/libs/granite/ui/components/foundation/form/radiogroup/index.html
- http://docs.adobe.com/docs/en/aem/6-0/develop/ref/granite-ui/api/jcr_root/libs/granite/ui/components/foundation/form/radio/index.html
NOTE:
If you are developing for AEM 6.3 then you will want the CoralUI3 flavour of all the components, i.e. instead of
granite/ui/components/foundation/form/radio
you should usegranite/ui/components/coral/foundation/form/radio
, etc.For details on migrating to CoralUI 3 see https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/granite-ui/api/jcr_root/libs/granite/ui/components/legacy/coral2/migration.html.
You can use Form Input - Radio . To create a radio button group give all radio buttons the same name. The resourceType of Radio input is /libs/granite/ui/components/foundation/form/radio
.
Sample Json of the Nodes :
"hideinnav": {
"jcr:primaryType": "nt:unstructured",
"name": "./hideInNav",
"text": "Hide in Navigation",
"value": "true",
"cq-msm-lockable": "hideInNav",
"sling:resourceType": "/libs/granite/ui/components/foundation/form/radio",
"renderReadOnly": true
},
"showinNav": {
"jcr:primaryType": "nt:unstructured",
"name": "./hideInNav",
"text": "Show in Navigation",
"value": "false",
"cq-msm-lockable": "hideInNav",
"sling:resourceType": "/libs/granite/ui/components/foundation/form/radio",
"renderReadOnly": true
}
Unlike the Classic UI Selection widget where the buttons are set under options node , radio buttons are independent and can be directly used in containers.

- 3,393
- 1
- 24
- 41
-
Thx for your answer. However, 2 small issues still persist. The first is, I am not able to give a field label to this radio group in Touch dialog. How can it be done? This is necessary since the author should know for what is he selecting a true/false radio options. The second is, the selection made by the author is not being preserved in the form of checked radio button the next time he opens the touch author dialog. This is not the case with classic dialog where the author's selection will be persisted in the form of checked radio button once the selection is made.Am I missing anything here? – Surya Chandra Dec 18 '14 at 04:30
-
-
Sharath, I have attached a screenshot of the properties of the node to the question. Please refer to it I cant try adding fieldLabel property as done in classic UI since there, we add it to the radiogroup node and provide options under the options node, bur here, each option is a separate node with sling:resourceType as radio. How to group them? And persisting the user selection, I don't see any property in the documentation which can achieve it. Let me know if you can help. – Surya Chandra Dec 18 '14 at 04:40
-
The text option is meant to be used as a label hence it doesn't have a fieldLabel. If you still want a common heading you can put the radio buttons in a fieldset and give fieldset a title. The values not being read back is strange , checked it now. Not sure why tough. Can't find any OOTB component with radio button. – Sharath Madappa Dec 18 '14 at 08:51
Coral UI3 no longer supports individual form/radio. This is now replaced by form/radio group https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/reference-materials/granite-ui/api/jcr_root/libs/granite/ui/components/legacy/coral2/migration.html
In Coral UI3, to create two radio buttons, you can do something like below:
<radioGroup
jcr:primaryType="nt:unstructured"
name=“./state“
text=“Select an Option”
sling:resourceType="granite/ui/components/coral/foundation/form/radiogroup">
<items jcr:primaryType="nt:unstructured">
<radioExpanded jcr:primaryType="nt:unstructured"
text="Expanded"
value="expanded”/>
<radioCollapse
jcr:primaryType="nt:unstructured"
text=“Collapse”
value=“collapse”/>
</items>
</radioGroup>

- 317
- 3
- 8
Radio button group is not supported in AEM 6 Touch UI. Instead, you could use a dropdown? sling:resourceType="granite/ui/components/foundation/form/dropdown"

- 15
- 2