The problem is that the type of the property that the tag handler exposes as an
attribute has to be assignable from the type of the expression. Taking the
current example:

<html:select styleClass="field" property="assignedTo">
  <logic:iterate id="element" name="employees">
    <html:option value="<%= ((java.util.Map.Entry)element).getKey() %>">
      <bean:write name="element" property="value.firstName"/>
      <bean:write name="element" property="value.lastName"/>
    </html:option>
  </logic:iterate>
</html:select>

The type of the expression is Object and the type of the tag handler's
(OptionTag) value property is String. So you'll end up with a compilation error
like:

setValue(java.lang.String) in org.apache.struts.taglib.html.OptionTag cannot be
applied to (java.lang.Object)

In which case, either of these should work:

<%= ((java.util.Map.Entry)element).getKey().toString() %>
<%= String.valueOf(((java.util.Map.Entry)element).getKey()) %>

If you know that the key really is a String, you could also cast:

<%= (String)((java.util.Map.Entry)element).getKey() %>

Quoting Rick Reumann <[EMAIL PROTECTED]>:

> On Tuesday, December 10, 2002, 5:06:26 PM, Kris wrote:
> 
> KS> Glad it's working, but I don't understand why you'd have a problem with
> the JSP
> KS> expression. IIRC, it's equivalent to the following code getting generated
> within
> KS> the page's _jspService method:
> 
>     Trust me I don't know either. I'm using Tomcat 4.0.6 if that
>     matters. It only causes me this problem when inside of a tag
>     trying to use <%= . I don't get it. Has anyone else ever ran into
>     this situation?
> 
>     
> -- 
> 
> Rick
> mailto:[EMAIL PROTECTED]
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to