Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help me with Struts HTML tags

 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I have this chunk of code in my JSP:

<html ption value = "<%=qvalue.getOid()%>" <%=str%>>
<bean:write name = "qvalue" property = "value" />
</html ption>

<%=str%> returns selected="selected" or null depending on some logic so that the option gets selected if the condition is true.
but,if i include <%=str%> it throws me exception:
Unterminated <html ption tag. If i remove and simply write
<html ption value = "<%=qvalue.getOid()%>" > it works fine.
How to get value selected while displaying page using html ption tags

Thanks,
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use a combination of <html:select> and <htmlption> tags, Struts automatically selects the correct option based on the value of the form bean property you specified in the <html:select> tag.

If you want to take over this logic yourself, I'd suggest using plain html (<select> and <option>) tags, rather than struts tags.
[ March 08, 2006: Message edited by: Merrill Higginson ]
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general the selected item is determined by the enclosing select tag. The following example calls the getLevel method on the form and option with the matching value is selected:


I am not sure how this translates into your requirements. You can also specify the html:select tag to allow multiple selections, in which case the form property would return an array of values.

- Brent

P.S. I have found the "Disable smilies in this post" option helpful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic