• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts select and options

 
jonathan Greens
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I am trying to use struts select and options tag.
In the following code, cell is a bean that represents an array of Strings,
<html:select property="<%=cellProperty.toString()%>" value="<%=valueToBeSelected%>">
<html ptionsCollection name="cell" property="" />
</html:select>

i have a hard time figuring out what property for optionsCollection should be...
the way it is now struts will say
No getter method for property of bean cell

thanks!
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jonathan,

I've never heard of an <htmlptionsCollection> tag, and I don't see it in the documentation. I'd suggest using <htmlptions>. Just specify a name with no property attribute. In this case, struts will assume that each element in the collection is a String and will use it as the list of options.
[ March 15, 2005: Message edited by: Merrill Higginson ]
 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

There is <html ptionsCollection> too .but this tag needs the label and value for each of the elment in ur collection. ie.each of iur element in the collection should have atleast one set and get methods ........or if u just have atsring array ,make that array of new LabelValueBean(String,String) (This LabelValueBean is given by struts) and that tag will work then

else its better as he mentioned use <html ptions name="cell"/>
 
jonathan Greens
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you both for answering my question!
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've had positive experiences with optionsCollection and Junilu has good things to say about it in his blog.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic