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 Struts Doubt 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 "Struts Doubt" Watch "Struts Doubt" New topic
Author

Struts Doubt

Phanindra varma
Greenhorn

Joined: Jul 29, 2005
Posts: 14
Hi All,

I have a doubt in struts can you please help me out in this.

Scenario:

I have two list boxes. If i select one item from first list box the page should get refreshed and display the associated item in the second list box. It is very urgent. Would anybody please help me out.
Thanks in Advance.
Wes Sorensen
Greenhorn

Joined: Dec 02, 2005
Posts: 13
I've seen this done with javascript. Never done it myself, but seen the code to do it. From what I remember, you have two sets of arrays. One has the first drop down list, the other is an array of all the other items, keyed off the first.

Then you disable the second drop down until an option is picked from the first. You watch for a onChange() for the first drop down, then repopulate the second (and enable if disabled).

Probably not very clear, sorry. That's the general idea, though. You have to "load" all options into the page, then update with javascript.

HTH

BTW, cars.com does this, so you can look at the page source there to get some ideas.
Kalyana Sundaram
Ranch Hand

Joined: Mar 18, 2005
Posts: 94
I would suggest you a simple solution for this. But it will work only if javaScriot is enabled in a webBrowser

In the JSP file, add onChange event handler for the first combobox.

if the list value is changed then the function
this time you will have to disable the second listbox


This form would get submitted to the action class which is configure in struts-config.xml.
In that action class retrieve the request parametr of the first list box
execute the logic to find the vvalues for the second listtbox
populate the form-bean and return the control to same JSP.
Now you will have the second list box populated with the values based on the first listbox

Hope this helps.


Only those who will risk going too far can possibly find out how far one can go !!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Doubt