jQuery in Action, 3rd edition
The moose likes Struts and the fly likes Help me with Struts HTML tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Help me with Struts HTML tags" Watch "Help me with Struts HTML tags" New topic

Help me with Struts HTML tags

Saathvik Reddy
Ranch Hand

Joined: Jun 03, 2005
Posts: 228
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

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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 ]

Consultant, Sima Solutions
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
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.
I agree. Here's the link: http://aspose.com/file-tools
subject: Help me with Struts HTML tags
It's not a secret anymore!