This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes How to create a set of interdependent drop down lists in struts 2. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to create a set of interdependent drop down lists in struts 2." Watch "How to create a set of interdependent drop down lists in struts 2." New topic
Author

How to create a set of interdependent drop down lists in struts 2.

kanishk dewan
Greenhorn

Joined: Aug 11, 2011
Posts: 9
Hi all,

Despite so many topics on this one I have not been able to figure it out for struts 2.

I have 5 drop down lists, and I want that a change in the selection of any one of these, should cause change in the contents of other drop downs without loading the complete page again, i.e asynchronously.

What I am currently trying is (using dojo) :

1.) When the selection of any of drop downs changes, the onChange event publishes a dojo topic.

2.) A topic listener causes an action to be executed.

Up to this point its fine. The action gets executed and sets the lists for the drop downs as expected.

Now what should happen is that :

--> When the action has completely executed it should come back to the same page (set in the struts config file) and update the lists of the drop downs with the new lists set in the action class.

I can not figure out how to do this.

Please help.
Also if there is a better way of doing it please help me out with it, along with the codes please.

Here is the code of what I have done:

The jsp page containing the drop downs.



the struts config file:


The action class just sets the lists for the drop downs. I have checked that it works fine.

Please help asap.

Thanks!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to create a set of interdependent drop down lists in struts 2.