Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

struts: html:options tag not working

 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic