You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Katarina Nelson <ka...@appium.com> on 2001/03/03 23:50:10 UTC

Iterate tag error: Cannot create iterator for this collection

Hi all,

I know that my question is common, but I´m still struggling with the iterate
tag.
Please can somebody help me?
When I´m using the logic:iterate tag I get only the following error:
"javax.servlet.ServletException: Cannot create iterator for this collection"

The not working code is:

<jsp:useBean id="myUser" scope="session" class="com.aspo.Model.User"/>

<logic:iterate id="profile" name="myUser" property="userProfiles">
<tr>
    <td align="left">
      <bean:write name="profile" property="name" filter="true"/>
    </td>
</tr>
</logic:iterate>

****************************************************************************
********
The same iteration works with this code:

<%
ListIterator profileIterator = myUser.getUserProfiles().findAll();
    while (profileIterator != null && profileIterator.hasNext()) {
         UserProfile profile = (UserProfile) profileIterator.next();
%>
<tr>
    <td width="330px"><a class="list" href="editProfile.do?action=Edit"><%=
profile.getName() %></a></td>
</tr>
<%
}
%>

Can anybody tell me what I'm doing wrong?
Thanks,

Katarina




Latest nightly build still on 24 Feb?

Posted by Michael Mok <mo...@hotmail.com>.
Hi

Is the latest nightly build available for download still at 24 Feb 2001? I went to the website this morning and notice that the latest build is dated 24 Feb 2001.

TIA

Michael Mok
www.webappcabaret.com/teatimej

RE: Iterate tag error: Cannot create iterator for this collection

Posted by Katarina Nelson <ka...@appium.com>.
See below for my comment:
  -----Original Message-----
  From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
  Sent: den 5 mars 2001 01:27
  To: struts-user@jakarta.apache.org
  Subject: Re: Iterate tag error: Cannot create iterator for this collection


  Katarina Nelson wrote:
     Hi all,I know that my question is common, but I´m still struggling with
the iterate tag.Please can somebody help me?When I´m using the logic:iterate
tag I get only the following error:
    "javax.servlet.ServletException: Cannot create iterator for this
collection"
    The not working code is: <jsp:useBean id="myUser" scope="session"
class="com.aspo.Model.User"/>
    <logic:iterate id="profile" name="myUser" property="userProfiles">
    <tr>
        <td align="left">
          <bean:write name="profile" property="name" filter="true"/>
        </td></tr>
    </logic:iterate>

****************************************************************************
********
    The same iteration works with this code:<%
    ListIterator profileIterator = myUser.getUserProfiles().findAll();
    while (profileIterator != null && profileIterator.hasNext())

    UserProfile profile = (UserProfile) profileIterator.next();
    %>
    <tr><td width="330px"><a class="list"
href="editProfile.do?action=Edit"><%= profile.getName() %></a></td>
    </tr>
    <%}%>Can anybody tell me what I'mdoing wrong?
    Thanks,Katarina

  What kind of object does the getUserProfiles() method return?  In order
for Struts to work, this must be an array, a Collection, an Iterator, or a
Map.  The fact that your code has to call findAll() to get an iterator
implies that your method does not return one of these.
  [Katarina Nelson] It's return an object "UserProfiles":

  public UserProfiles getUserProfiles() {
        return userProfiles;
     }

  So, is it impossible to by using the findAll() (which returns
ListItrerator) iterate the "profile"?
  Thanks
  Katarina
  Craig McClanahan



Re: Iterate tag error: Cannot create iterator for this collection

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Katarina Nelson wrote:

>  Hi all,I know that my question is common, but I´m still struggling
> with the iterate tag.Please can somebody help me?When I´m using
> the logic:iterate tag I get only the following error:
> "javax.servlet.ServletException: Cannot create iterator for this
> collection"
>
> The not working code is: <jsp:useBean id="myUser" scope="session"
> class="com.aspo.Model.User"/>
> <logic:iterate id="profile" name="myUser" property="userProfiles">
> <tr>
>     <td align="left">
>       <bean:write name="profile" property="name" filter="true"/>
>     </td></tr>
> </logic:iterate>
>
> ***********************************************************************************
>
> The same iteration works with this code:<%
> ListIterator profileIterator = myUser.getUserProfiles().findAll();
> while (profileIterator != null && profileIterator.hasNext()) {
> UserProfile profile = (UserProfile) profileIterator.next();
> %>
> <tr><td width="330px"><a class="list"
> href="editProfile.do?action=Edit"><%= profile.getName() %></a></td>
> </tr>
> <%}%>Can anybody tell me what I'mdoing wrong?
> Thanks,Katarina

What kind of object does the getUserProfiles() method return?  In order
for Struts to work, this must be an array, a Collection, an Iterator, or
a Map.  The fact that your code has to call findAll() to get an iterator
implies that your method does not return one of these.

Craig McClanahan