File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes populate dropdown with database values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "populate dropdown with database values" Watch "populate dropdown with database values" New topic
Author

populate dropdown with database values

shah rah
Ranch Hand

Joined: Jan 04, 2007
Posts: 124
I have a simple search screen where the user enters group ID. The next screen should populate all the subgroups for this groupID inside a dropdown.

I know my select statement. I don't want to do the db access inside JSP page.

I think it should be done inside the Action class that is invoked when user enters groupID and submit is pressed. My question is how do I put the values inside the dropdown from my Action class.

Pls guide me.
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
You should have an action for form submittal for when the user selects the initial group id. That action should forward to the page that shows the second select box.

In this action, you should populate a LabelValueBean with the corresponding labels and values of the groups you want in the drop down (that you get from the database). Throw that LabelValueBean into your form and the action will forward to the jsp page (should only have display information in it). You should use html:select and html ptionsCollection to display the drop down.
 
 
subject: populate dropdown with database values