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

Add selected as true to dynamic dropdown

Avatar

Avatar
Springboard
Level 6
snbaem
Level 6

Likes

93 likes

Total Posts

218 posts

Correct Reply

29 solutions
Top badges earned
Springboard
Establish
Validate 25
Validate 10
Validate 1
View profile

Avatar
Springboard
Level 6
snbaem
Level 6

Likes

93 likes

Total Posts

218 posts

Correct Reply

29 solutions
Top badges earned
Springboard
Establish
Validate 25
Validate 10
Validate 1
View profile
snbaem
Level 6

03-02-2020

Hello All, I am trying to follow https://helpx.adobe.com/experience-manager/using/creating-touchui-dynamic.html and able to get the dynamic dropdown. However if I want to have a second dropdown value as selected I am unable to do so. Am I missing something?

 

I am trying following

DataSource ds = new SimpleDataSource(new TransformIterator(languages.keySet().iterator(), new Transformer() {
       public Object transform(Object o) {
           String language = (String) o;
           ValueMap vm = new ValueMapDecorator(new HashMap<String, Object>());
 
           vm.put("value", language);
           vm.put("text", languages.get(language));
//my custom
if(selctedLanguage==true) {
vm.put("selected", true);
}
 
           return new ValueMapResource(resolver, new ResourceMetadata(), "nt:unstructured", vm);
       }
   }));

. Still the drop down values show as top one selected. 

 

cc @Arun_Patidar I have looked at aem63app-repo/dynamic-dropdown.js at master · arunpatidar02/aem63app-repo · GitHub but I want to achieve this when I am populating the second dropdown via datasource. Using a ./hiddenproperty did not work for me...

AEM 6.4 dynamic dropdown

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Springboard
Level 6
snbaem
Level 6

Likes

93 likes

Total Posts

218 posts

Correct Reply

29 solutions
Top badges earned
Springboard
Establish
Validate 25
Validate 10
Validate 1
View profile

Avatar
Springboard
Level 6
snbaem
Level 6

Likes

93 likes

Total Posts

218 posts

Correct Reply

29 solutions
Top badges earned
Springboard
Establish
Validate 25
Validate 10
Validate 1
View profile
snbaem
Level 6

04-02-2020

As mentioned in first comment I was able to achieve this by adding disabled=true for selected item. Thanks again to @Arun_Patidar for the great article

Answers (2)

Answers (2)

Avatar

Avatar
Give Back 5
Employee
sunjot16
Employee

Likes

105 likes

Total Posts

164 posts

Correct Reply

50 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 25
Give Back 10
Give Back
View profile

Avatar
Give Back 5
Employee
sunjot16
Employee

Likes

105 likes

Total Posts

164 posts

Correct Reply

50 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 25
Give Back 10
Give Back
View profile
sunjot16
Employee

03-02-2020

Once the select tag is created, you can read that document element using query selector, parse through its options and set the "selected" attribute to the second option.

 

Hope it helps !!

Avatar

Avatar
Springboard
Level 6
snbaem
Level 6

Likes

93 likes

Total Posts

218 posts

Correct Reply

29 solutions
Top badges earned
Springboard
Establish
Validate 25
Validate 10
Validate 1
View profile

Avatar
Springboard
Level 6
snbaem
Level 6

Likes

93 likes

Total Posts

218 posts

Correct Reply

29 solutions
Top badges earned
Springboard
Establish
Validate 25
Validate 10
Validate 1
View profile
snbaem
Level 6

10-02-2020

Already added wha worked for me. This can be disregaded.