Servlet for Dynamic dropdown in dialog | Community
Skip to main content
January 21, 2022
Solved

Servlet for Dynamic dropdown in dialog

  • January 21, 2022
  • 3 replies
  • 2591 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Magicr

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

3 replies

manikanthar1295
January 21, 2022

HI @ronnie09 ,

 

You can see below example how we can get the dynamic value in dropdown.

 

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

 

Regards

Manikantha R

Ronnie09Author
January 21, 2022

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

imadullakhan
January 21, 2022

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

Magicr
MagicrAccepted solution
January 21, 2022

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