Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

populating list boxes in forms - help required

 
Ahsan Hadi
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"/>
</html:select>
The values will submitted to a single form, please advise if the approach is correct.
thanks,
Ahsan.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic