Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Radio button value persists but not retrieved in touch UI dialog

Avatar

Avatar
Validate 1
Level 2
angthefire
Level 2

Likes

3 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
angthefire
Level 2

Likes

3 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile
angthefire
Level 2

07-11-2017

I have a set of radio buttons (top, center and bottom). My requirement is such that I have used the property "checked" as true to show "center" as the selected one when the component is dragged and dropped on the page.

If I open the dialog, selects the radio button "top" and click submit, I am getting the value as "top" in my html page. But, if I reopen the dialog, the "center" button is selected instead of "top".

As per requirement, I can't change the order of radio button as well as default selection.

Replies

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

07-11-2017

If you look at docs - you can set default - Radio — Granite UI 1.0 documentation

Have you tried that?

Avatar

Avatar
Validate 1
Level 2
angthefire
Level 2

Likes

3 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
angthefire
Level 2

Likes

3 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile
angthefire
Level 2

07-11-2017

Hi smacdonald2008,

Thanks for the reply.

The issue here is not with setting the default value. Let me try to explain the issue with the help of some snapshots.

1343571_pastedImage_1.png

The above snapshot shows the selection of "center" radio button (which I achieved via checked(boolean) property).

1343572_pastedImage_2.png

I selected the "Top" radio button and clicked submit.

Now if I reopen the dialog, I see the following:

1343573_pastedImage_6.png

I hope the question is more clear than before.

Thanks

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

07-11-2017

You see that because it has the prop checked. Therefore each time you open a dialog - the checked property is used, This would be the same for any form that has a radio group and one radio option is set as default. As a result, each time an author opens the dialog and wants another value, they will have to select either Top or Bottom.

Avatar

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

273 likes

Total Posts

1,502 posts

Correct Reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

273 likes

Total Posts

1,502 posts

Correct Reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
edubey
Level 10

12-02-2018

Below is the structure which I used and work. You can refer

{

"jcr:primaryType": "nt:unstructured",

"personalyes": {

"jcr:primaryType": "nt:unstructured",

"name": "./myValue",

"text": "Yes",

"value": "yes",

"sling:resourceType": "granite/ui/components/foundation/form/radio"

},

"personalno": {

"jcr:primaryType": "nt:unstructured",

"name": "./myValue",

"text": "No",

"value": "no",

"sling:resourceType": "granite/ui/components/foundation/form/radio"

},

"defaultvalue": {

"jcr:primaryType": "nt:unstructured",

"name": "./myValue@DefaultValue",

"value": "no",

"sling:resourceType": "granite/ui/components/foundation/form/hidden"

},

"defaultwhenmissing": {

"jcr:primaryType": "nt:unstructured",

"name": "./myValue@UseDefaultWhenMissing",

"value": "true",

"sling:resourceType": "granite/ui/components/foundation/form/hidden"

}

}

Avatar

Avatar
Validate 10
Level 2
anelem1760873
Level 2

Likes

9 likes

Total Posts

59 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile

Avatar
Validate 10
Level 2
anelem1760873
Level 2

Likes

9 likes

Total Posts

59 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile
anelem1760873
Level 2

15-05-2018

Hi Guys,

Has anyone find the solution for this, am also facing the same issue.

Thanks

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,273 likes

Total Posts

3,151 posts

Correct Reply

887 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,273 likes

Total Posts

3,151 posts

Correct Reply

887 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

15-05-2018

I used coral3 radio granite/ui/components/coral/foundation/form/radiogroup

working for me as expecting without adding extra node/property

Avatar

Avatar
Level 1
anirudh_sharma1
Level 1

Likes

0 likes

Total Posts

4 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
anirudh_sharma1
Level 1

Likes

0 likes

Total Posts

4 posts

Correct Reply

0 solutions
View profile
anirudh_sharma1
Level 1

25-06-2018

As per the documentation - RadioGroup — Granite UI 1.0 documentation, you can try the following -

<testRadioGroup

     jcr:primaryType="nt:unstructured"

     sling:resourceType="granite/ui/components/foundation/form/radiogroup"

     ignoreData="{Boolean}false"

     text="Test Radio"

     vertical="{Boolean}true">

     <items jcr:primaryType="nt:unstructured">

        <option1

           jcr:primaryType="nt:unstructured"

           sling:resourceType="granite/ui/components/foundation/form/radio"

           checked="{Boolean}true"

           name="./testRadio"

           text="Option 1"

           value="option1"/>

        <option2

           jcr:primaryType="nt:unstructured"

           sling:resourceType="granite/ui/components/foundation/form/radio"

           name="./testRadio"

           text="Option 2"

           value="option2"/>

     </items>

</testRadioGroup>

I tested this on AEM 6.4 and it is working fine for me. The trick has been done by the ignoreData property. Happy coding

Avatar

Avatar
Level 1
Akash_Ramchanda
Level 1

Likes

0 likes

Total Posts

5 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
Akash_Ramchanda
Level 1

Likes

0 likes

Total Posts

5 posts

Correct Reply

0 solutions
View profile
Akash_Ramchanda
Level 1

11-07-2018

Hi Anirudh,

Can you set the checked property on the second option and test the same.

We are facing the same issue and looking for a solution for it ASAP.

We are still using 6.2 and I am sure that AEM version has nothing to do with it because the granite version is the same.

Avatar

Avatar
Boost 3
Employee
kenccwong
Employee

Likes

4 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Boost 3
Boost 1
View profile

Avatar
Boost 3
Employee
kenccwong
Employee

Likes

4 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Boost 3
Boost 1
View profile
kenccwong
Employee

13-12-2018

It looks like /libs/granite/ui/components/foundation/form/radio/radio.jsp is not following the specification correctly. What it does is first checks if "checked" property is available, if not available then it will check if "ignoreData" is set to false in the parent radio group.

Workaround is to create an overlay and add an additional check to see if a value is set.

    if (cfg.get("checked", String.class) != null && val.getContentValue(name) == "") {

        // providing "checked" in configuration results in ignoring content data

        attrs.addChecked(cfg.get("checked", false));

    } else if (!cfg.getInherited("ignoreData", false)) {

        // mark checked if content value equals config value

        attrs.addChecked(val.getContentValue(name).equals(value));

    }