Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts: html:options tag not working

 
Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following sort of working -

selectedGoalID is the get/set in my browseform (aka the browse bean)
I have a class called goal with a getName method.
The form returns an arraylist of goals.
The above tag will generate a select box with 4 options, the number of goals I have. The names are completely wrong, as I would expect. What I need is this -
- a value for each goal, the goal's id
- a displayed option, the goal's name
- the selected goal needs to remain selected after going through the action form
The following is what 'works' in the sense, it displays the names and has the value associated with id. It keeps reseting to the first option after going through the action though.

The Mastering Jakarata Struts book by J. Goodwill only provides a simple example. I haven't gotten a better understanding from the struts docs either.
What am I missing?
Regards,
Aaron R>
[ September 26, 2002: Message edited by: Aaron Roberts ]
 
Ravi Veera
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an example adaptedfrom my code which may be wwhat you are looking for

In this example in my pipingForm class I have an ArrayList element called projectUnits and a corresponding getProjectUnits method. The projectUnits ArrayList is populated with instances of the LabelValueBean class(having label and value properties).
HTT
Ravi
[ September 27, 2002: Message edited by: Ravi Veeraghanta ]
 
Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I adjusted your example for my specific beans and methods and everything worked perfectly! Thank you so much for the help!
I was able to replace the half html / half struts select box I had created with a straight struts implementation.
If I understand it, the reason I couldn't just use the returned arraylist directly, was because the options tag only does a get on the property and labelproperty parameters. I had to already have a collection in the form bean or define it explicitly as you showed.
Best regards,
Aaron
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic