File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Doubt" Watch "Struts Doubt" New topic

Struts Doubt

Phanindra varma

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

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


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

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.


BTW, 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:
subject: Struts Doubt
It's not a secret anymore!