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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Servlet for Dynamic dropdown in dialog

Avatar

Level 6

I have country and states name which should change as per country selection 

How to write the servlet (I dont have ValueMapDecorator in my aem).

Country: States

 

India- Himachal, UP,  UK, etc

Australia- Queensland, Tasmania etc

UAE- Abu dhabi, Ajman, Dubai, etc

 

Need help I am doing this for first time.

1 Accepted Solution

Avatar

Correct answer by
Level 6

Years ago I faced to the same challenge. It was very hard work to finished it.

My way was as follow:

- I created a custom dialog means using own html, css and javascript and of course slighty. The drop down lists, for me there were three depending lists, are type of AEM component

<coral-select></coral-select>

The code wich controls the behaviour is written in client side javascript -currently still in jquery.

- On serverside there is a model class that does provide only the content for the lists. He is represented by created pages. The linked templates containing only necassary information, keeping complexity low.

- Slighty transfers the content from backend to frontend. For this I have created three html elements whose are hidden by using css attribute "display:none;".

- Client side javascript does the rest. Means creates the drop down items, fill them from hidden elements above and controls the behavior.

 

It might be not the best way to solve it, but it works for years and allows the authors to fill the content by thier own. 🙂

View solution in original post

0 Replies

Avatar

Level 6

I cant achieve for 2 dropdown 

Country: States

 

India- Himachal, UP,  UK, etc

Australia- Queensland, Tasmania etc

UAE- Abu dhabi, Ajman, Dubai, etc

 

If India chosen in one dropdown other should ppulated with Himachal, up and all

Avatar

Level 4

Hi @Ronnie09,

 

Please write the Servlet on GET request. And you can pass the dropdown values from backend servlet or from your component dialog box. Please follow the below URL also if you have more confusion.

 

http://www.sgaemsolutions.com/2019/01/dynamically-populate-drop-down-values.html

 

Thanks,

Imad

Avatar

Correct answer by
Level 6

Years ago I faced to the same challenge. It was very hard work to finished it.

My way was as follow:

- I created a custom dialog means using own html, css and javascript and of course slighty. The drop down lists, for me there were three depending lists, are type of AEM component

<coral-select></coral-select>

The code wich controls the behaviour is written in client side javascript -currently still in jquery.

- On serverside there is a model class that does provide only the content for the lists. He is represented by created pages. The linked templates containing only necassary information, keeping complexity low.

- Slighty transfers the content from backend to frontend. For this I have created three html elements whose are hidden by using css attribute "display:none;".

- Client side javascript does the rest. Means creates the drop down items, fill them from hidden elements above and controls the behavior.

 

It might be not the best way to solve it, but it works for years and allows the authors to fill the content by thier own. 🙂