How to set default value in a Touch UI select element?

Avatar

Avatar
Boost 3
Level 1
andrew_bowles
Level 1

Likes

3 likes

Total Posts

4 posts

Correct reply

1 solution
Top badges earned
Boost 3
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Boost 3
Level 1
andrew_bowles
Level 1

Likes

3 likes

Total Posts

4 posts

Correct reply

1 solution
Top badges earned
Boost 3
Validate 1
Boost 1
Affirm 1
View profile
andrew_bowles
Level 1

02-11-2015

I am trying to set the defaultValue in a Touch UI select dropdown. Setting "defaultValue" in dialog.xml works in Classic mode, but not in Touch. Here is the relevant snippet from my component's .content.xml <alignment jcr:primaryType="cq:Widget" sling:resourceType="granite/ui/components/foundation/form/select" fieldLabel="Alignment" name="./alignment" value="option2" defaultValue="option2"> <items jcr:primaryType="cq:WidgetCollection"> <topLeft jcr:primaryType="nt:unstructured" text="Option 1" value="option1"/> <topCenter jcr:primaryType="nt:unstructured" text="Option 2" value="option2"/> <topRight jcr:primaryType="nt:unstructured" text="Option3" value="option3"/> </items> </alignment>

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 3
Level 1
andrew_bowles
Level 1

Likes

3 likes

Total Posts

4 posts

Correct reply

1 solution
Top badges earned
Boost 3
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Boost 3
Level 1
andrew_bowles
Level 1

Likes

3 likes

Total Posts

4 posts

Correct reply

1 solution
Top badges earned
Boost 3
Validate 1
Boost 1
Affirm 1
View profile
andrew_bowles
Level 1

10-11-2015

It seems that this is a bug with the granite select component (granite/ui/components/foundation/form/select).

The problem was also posted here, and never solved: http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

Answers (11)

Answers (11)

Avatar

Avatar
Boost 1
Level 1
matteom53776983
Level 1

Like

1 like

Total Posts

1 post

Correct reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
matteom53776983
Level 1

Like

1 like

Total Posts

1 post

Correct reply

0 solutions
Top badges earned
Boost 1
View profile
matteom53776983
Level 1

10-06-2021

Hi,

in order to make it work isn't enough to add 

selected="{Boolean}true" 
in the option you want as default, you have also to set

forceIgnoreFreshness="{Boolean}true"

in the select node itself.

Avatar

Avatar
Validate 1
Level 1
BhargavThogata
Level 1

Like

1 like

Total Posts

4 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
BhargavThogata
Level 1

Like

1 like

Total Posts

4 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
BhargavThogata
Level 1

20-04-2016

Hi,

Checked selected={Boolean}true. works fine in AEM 6.1 with SP2 installed.

 

Thanks,

Bhargav

Avatar

Avatar
Level 1
darakhshan_shei
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
View profile

Avatar
Level 1
darakhshan_shei
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
View profile
darakhshan_shei
Level 1

24-02-2016

Hi Loki,

selected boolean true doesnt work to set a property as a default . Can you please guide on a solution to this.

Avatar

Avatar
Boost 1
Level 1
andrew_bowles1
Level 1

Like

1 like

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
andrew_bowles1
Level 1

Like

1 like

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Boost 1
View profile
andrew_bowles1
Level 1

24-02-2016

I was never able to find a solution. selected="{Boolean}true" hasn't worked for me. 

Avatar

Avatar
Level 1
darakhshan_shei
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
View profile

Avatar
Level 1
darakhshan_shei
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
View profile
darakhshan_shei
Level 1

24-02-2016

Andrew Bowles wrote...

I am making the change directly in the component's .content.xml, but selected="{Boolean}true" hasn't worked either. It seems to always default to the first option.

 


Did you get a solution for this ? selected = true (as a boolean property) doesnt work. If you have some other solution plz share.

Avatar

Avatar
Boost 3
Level 1
andrew_bowles
Level 1

Likes

3 likes

Total Posts

4 posts

Correct reply

1 solution
Top badges earned
Boost 3
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Boost 3
Level 1
andrew_bowles
Level 1

Likes

3 likes

Total Posts

4 posts

Correct reply

1 solution
Top badges earned
Boost 3
Validate 1
Boost 1
Affirm 1
View profile
andrew_bowles
Level 1

09-11-2015

I am making the change directly in the component's .content.xml, but selected="{Boolean}true" hasn't worked either. It seems to always default to the first option.

Avatar

Avatar
Validate 25
MVP
bsloki
MVP

Likes

183 likes

Total Posts

1,859 posts

Correct reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile

Avatar
Validate 25
MVP
bsloki
MVP

Likes

183 likes

Total Posts

1,859 posts

Correct reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
bsloki
MVP

09-11-2015

if you are changing directly in the xml, it should be like

selected="{Boolean}true"

Avatar

Avatar
Validate 25
MVP
bsloki
MVP

Likes

183 likes

Total Posts

1,859 posts

Correct reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile

Avatar
Validate 25
MVP
bsloki
MVP

Likes

183 likes

Total Posts

1,859 posts

Correct reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
bsloki
MVP

09-11-2015

Have you added it as a String or boolean ?

Avatar

Avatar
Boost 3
Level 1
andrew_bowles
Level 1

Likes

3 likes

Total Posts

4 posts

Correct reply

1 solution
Top badges earned
Boost 3
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Boost 3
Level 1
andrew_bowles
Level 1

Likes

3 likes

Total Posts

4 posts

Correct reply

1 solution
Top badges earned
Boost 3
Validate 1
Boost 1
Affirm 1
View profile
andrew_bowles
Level 1

02-11-2015

I've added selected="true" to the second value in the dropdown, but the first value is still selected by default.

<horizontal jcr:primaryType="cq:Widget" sling:resourceType="granite/ui/components/foundation/form/select" fieldLabel="Horizontal Alignment" name="./halign"> <items jcr:primaryType="cq:WidgetCollection"> <topLeft jcr:primaryType="nt:unstructured" text="Left" value="hleft"/> <topCenter jcr:primaryType="nt:unstructured" text="Center" value="hcenter" selected="true"/> <topRight jcr:primaryType="nt:unstructured" text="Right" value="hright"/> </items> </horizontal>

Avatar

Avatar
Validate 25
MVP
bsloki
MVP

Likes

183 likes

Total Posts

1,859 posts

Correct reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile

Avatar
Validate 25
MVP
bsloki
MVP

Likes

183 likes

Total Posts

1,859 posts

Correct reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
bsloki
MVP

02-11-2015

Basically, you need to add 'selected' property which takes a boolean for the option which you want. by default it will be 'false'

Avatar

Avatar
Validate 25
MVP
bsloki
MVP

Likes

183 likes

Total Posts

1,859 posts

Correct reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile

Avatar
Validate 25
MVP
bsloki
MVP

Likes

183 likes

Total Posts

1,859 posts

Correct reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
bsloki
MVP

02-11-2015

defaultValue doesnt work in Touch UI.

If you want Option 2 be set as defaultValue. try using this 

 

  1. <alignment
  2. jcr:primaryType="cq:Widget"
  3. sling:resourceType="granite/ui/components/foundation/form/select"
  4. fieldLabel="Alignment"
  5. name="./alignment"
  6. value="option2"
  7. defaultValue="option2">
  8. <items jcr:primaryType="cq:WidgetCollection">
  9. <topLeft
  10. jcr:primaryType="nt:unstructured"
  11. text="Option 1"
  12. value="option1"/>
  13. <topCenter
  14. jcr:primaryType="nt:unstructured"
  15. text="Option 2"
  16. value="option2"
  17. selected="true"/>
  18. <topRight
  19. jcr:primaryType="nt:unstructured"
  20. text="Option3"
  21. value="option3"/>
  22. </items>
  23. </alignment>