You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Eddie Yan <ed...@streamyx.com> on 2004/06/23 18:06:19 UTC

Logic:Iterate Problem

Hi guys,

Say I have a JSP as follows:

<table>
<tr>
 <%
     Iterator iter = pageRecords.iterator();
     while(iter.hasNext())
     {
         UserDetail detail = (UserDetail)iter.next();
 %>
 <td>   <%= detail.getId() %> </td>
<%
    }
%>
</tr>
</table>

pageRecords is a Collection of UserDetail object.
UserDetail is my data transfer object.
I can manage to get the expected result of detail.getId()

How can I represent the above code in <logic:iterate> tags ? 
The following code doesn't work.

<table>
<tr>
<logic:iterate id="myID" collection="pageRecords" property="UserDetail">
  <td> <bean:write name="myID" property="id" /> </td>
</logic:iterate>
</tr>
</table>

I got JSP Exception: Cannot create iterator for this collection





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


R: Logic:Iterate Problem

Posted by Amleto Di Salle <di...@di.univaq.it>.
Hi,
you can use the JSTL1.1 (or 1.0 as you want) in the following way:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

........

<table>
    <c:forEach items="${requestScope.pageRecords}" var="row">
		<tr><c:out value="${row.Id}"/></tr>
    </c:forEach>
</table>

you can use "pageScope", "requestScope", "sessionScope" or
"applicationScope" depending on the "pageRecords" is stored.

BR
/Amleto


-----Messaggio originale-----
Da: Eddie Yan [mailto:eddieyan@streamyx.com] 
Inviato: mercoledì 23 giugno 2004 18.06
A: user@struts.apache.org
Oggetto: Logic:Iterate Problem


Hi guys,

Say I have a JSP as follows:

<table>
<tr>
 <%
     Iterator iter = pageRecords.iterator();
     while(iter.hasNext())
     {
         UserDetail detail = (UserDetail)iter.next();
 %>
 <td>   <%= detail.getId() %> </td>
<%
    }
%>
</tr>
</table>

pageRecords is a Collection of UserDetail object.
UserDetail is my data transfer object.
I can manage to get the expected result of detail.getId()

How can I represent the above code in <logic:iterate> tags ? 
The following code doesn't work.

<table>
<tr>
<logic:iterate id="myID" collection="pageRecords" property="UserDetail">
  <td> <bean:write name="myID" property="id" /> </td> </logic:iterate>
</tr> </table>

I got JSP Exception: Cannot create iterator for this collection





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Logic:Iterate Problem

Posted by Robert Taylor <rt...@mulework.com>.
Assuming you have a scoped Collection named "pageRecords":

Struts tags:
<logic:iterate id="myID" name="pageRecords">
   <td> <bean:write name="myID" property="id" /> </td>
</logic:iterate>

JSTL:
<c:forEach var="user" items="${pageRecords}">
<c:out value="${user.id}"/>
</c:forEach>

robert

> -----Original Message-----
> From: Eddie Yan [mailto:eddieyan@streamyx.com]
> Sent: Wednesday, June 23, 2004 12:06 PM
> To: user@struts.apache.org
> Subject: Logic:Iterate Problem
> 
> 
> Hi guys,
> 
> Say I have a JSP as follows:
> 
> <table>
> <tr>
>  <%
>      Iterator iter = pageRecords.iterator();
>      while(iter.hasNext())
>      {
>          UserDetail detail = (UserDetail)iter.next();
>  %>
>  <td>   <%= detail.getId() %> </td>
> <%
>     }
> %>
> </tr>
> </table>
> 
> pageRecords is a Collection of UserDetail object.
> UserDetail is my data transfer object.
> I can manage to get the expected result of detail.getId()
> 
> How can I represent the above code in <logic:iterate> tags ? 
> The following code doesn't work.
> 
> <table>
> <tr>
> <logic:iterate id="myID" collection="pageRecords" property="UserDetail">
>   <td> <bean:write name="myID" property="id" /> </td>
> </logic:iterate>
> </tr>
> </table>
> 
> I got JSP Exception: Cannot create iterator for this collection
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


R: Logic:Iterate Problem

Posted by Amleto Di Salle <di...@di.univaq.it>.
Hi,
you can use the JSTL1.1 (or 1.0 as you want) in the following way:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

........

<table>
    <c:forEach items="${requestScope.pageRecords}" var="row">
		<tr><c:out value="${row.Id}"/></tr>
    </c:forEach>
</table>

you can use "pageScope", "requestScope", "sessionScope" or
"applicationScope" depending on the "pageRecords" is stored.


-----Messaggio originale-----
Da: Eddie Yan [mailto:eddieyan@streamyx.com] 
Inviato: mercoledì 23 giugno 2004 18.06
A: user@struts.apache.org
Oggetto: Logic:Iterate Problem


Hi guys,

Say I have a JSP as follows:

<table>
<tr>
 <%
     Iterator iter = pageRecords.iterator();
     while(iter.hasNext())
     {
         UserDetail detail = (UserDetail)iter.next();
 %>
 <td>   <%= detail.getId() %> </td>
<%
    }
%>
</tr>
</table>

pageRecords is a Collection of UserDetail object.
UserDetail is my data transfer object.
I can manage to get the expected result of detail.getId()

How can I represent the above code in <logic:iterate> tags ? 
The following code doesn't work.

<table>
<tr>
<logic:iterate id="myID" collection="pageRecords" property="UserDetail">
  <td> <bean:write name="myID" property="id" /> </td> </logic:iterate>
</tr> </table>

I got JSP Exception: Cannot create iterator for this collection





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org