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
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:
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.