Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:options in struts

 
shawn kennedy
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I have a drop down box that contains a list of choices when a user clicks on a choice a second drop down box gets populated and the user can choose something from there.At this time the item that has been chosen in the first drop down box should be selected so the database can be populated with both the choices.My problem is i dont know how to use html ptions tag so if one could provide a comprehensive example with what all additions are to be made in the struts action class /action form and where all they have to be made it would be great.Also how i could highlight the option og the first drop down with what the user has chosen.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
options tag

<html:select property="selectedPerson">
<html ptions property="people"/>
</html:select>

ActionForm requires:
getSelectedPerson() / setSelectedPerson()
getPeople() - returns a collection

If the form has a value for selectedPerson, Struts will automatically prepopulate it as the selected option. That's mainly why we use the Struts tags - prepopulation.

The Action class... well that's your own business to do what you want with that selectedPerson value from the form.

That should be pretty comprehensive. I can answer other questions but to be any more specific I'm afraid I'd have to ask for your paycheck.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic