I think you need to say name="roles" instead of collection="roles".
Assuming there is as roles.getValue() accessor, the rest looks fine.
If not, you may just need <bean:write:element> if the objects in roles
have a toString() method.
Simon Liang wrote:
>
> Hi:
>
> Can someone help with this? I can't find an example whether struts iterate
> throught a collection.
> <!-------------------- The code ----------------------%>
> <%
> java.util.Collection roles = client.getUserRoles("admin");
> %>
>
> <logic:iterate id="element" collection="roles">
> <H4>Next element is <bean:write name="element" property="value"/></H4>
> </logic:iterate>
> <!------------------End the code ---------------------%>
>
> The error:
>
> admin/umModifyOrg.jsp(-1): Error in tag library at: 'logic': for tag
> 'iterate', property 'collection' of tag handler class
> 'org.apache.struts.taglib.logic.IterateTag', the property value must be a
> runtime expression "<%=...%>", since we cannot do an automatic convertion
> from "roles" to type 'java.lang.Object'
> probably occurred due to an error in /admin/umModifyOrg.jsp line -1:
>
> ============================================================================
> This message is intended only for the use of the Addressee(s) and may
> contain information that is PRIVILEGED and CONFIDENTIAL. If you are not
> the intended recipient, dissemination of this communication is prohibited.
> If you have received this communication in error, please erase all copies
> of the message and its attachments and notify [EMAIL PROTECTED]
> immediately.
> ============================================================================
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/