• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help me with Struts HTML tags

 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you use a combination of <html:select> and <html:option> 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 ]
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic