File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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.
It is sorta covered in the JavaRanch Style Guide.
subject: populating list boxes in forms - help required
It's not a secret anymore!