This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Struts and the fly likes populating list boxes in forms - help required Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Frameworks » Struts
Bookmark "populating list boxes in forms - help required" Watch "populating list boxes in forms - help required" New topic

populating list boxes in forms - help required

Ahsan Hadi

Joined: Jul 12, 2002
Posts: 19
Hello Everybody,
I am new to the struts framework, so please bear with me. I am trying to create a struts form which has select boxes which are populated from the values coming from the database. Correct me if I am wrong: i can do this by having the previous action to put a class in request which has vectors filled with the required values, but then how do i retrive from these vectors to display things in my jsp and form the selects.

David Yutzy
tumbleweed and gunslinger
Ranch Hand

Joined: Jun 29, 2001
Posts: 192
If these list boxes are for a single form, then populate the FormBean with a method of type LabelValueBean. The select then recognizes this (or any object array) to populate a typical SELECT.
Google on "LabelValueBean" for multiple code examples of exactly what you are trying to do.
If you are implying that you have vectors or something else that stays in session, you should be able to use the same logic to populate the SELECT.
Ahsan Hadi

Joined: Jul 12, 2002
Posts: 19
Many Thanks for your reply.
I did find some references on LabelValueBean on Google but no code example, perhaps you can point me to a resource. What I am trying to do:
Have JSP display which has some columns with select boxes, populated from the database. At the moment, the previous action to this jsp page is putting some vectors in request and below is how I am constructing the select:
<html:select name="fcst" property="strType">
<html ptions collection="type" property="value" labelProperty="label"/>
The values will submitted to a single form, please advise if the approach is correct.
I agree. Here's the link:
subject: populating list boxes in forms - help required
jQuery in Action, 3rd edition