You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Geoffrey Mroz <st...@japache.org> on 2002/01/10 15:30:45 UTC
Re: quick question: nested Iterate process.
If I read you right, then the following should work (I just posted this to another question)
html>
<body>
Use of the Struts iterate tag with nested ArrayLists representing rows/cols:<p>
<%@ page import="java.util.ArrayList" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%
ArrayList rows = new ArrayList();
ArrayList rowOne = new ArrayList();
rowOne.add("bob");
rowOne.add("jones");
rowOne.add("bob@bob.com");
ArrayList rowTwo = new ArrayList();
rowTwo.add("ted");
rowTwo.add("Walters");
rowTwo.add("ted@ted.com");
ArrayList rowThree = new ArrayList();
rowThree.add("Mary");
rowThree.add("Smith");
rowThree.add("mary@mary.com");
rows.add(rowOne);
rows.add(rowTwo);
rows.add(rowThree);
request.setAttribute("DATASET",rows);
%>
<table border="1">
<logic:iterate id="eachRow" name="DATASET" scope="request">
<tr>
<logic:iterate id="eachCol" name="eachRow">
<td>
<bean:write name="eachCol" />
</td>
</logic:iterate>
</tr>
</logic:iterate>
</table>
</body>
</html>
Hope that helps.
-- Geoff
--
Sent via jApache.org
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: quick question: nested Iterate process.
Posted by Nick Thomson <nt...@envision.com>.
I have found with struts version 1.0 that if you have nested collections on
a form bean that struts will correctly reslove the getter methods but is
unable to resolve the setter methods. I have been forced to use scriptlets
inside the stuts tags to overcome this problem. I'm hoping the newest
version, 1.01 I think, has fixed this.
-----Original Message-----
From: Geoffrey Mroz [mailto:struts-user@japache.org]
Sent: Thursday, January 10, 2002 8:31 AM
To: struts-user@jakarta.apache.org
Subject: Re: quick question: nested Iterate process.
If I read you right, then the following should work (I just posted this to
another question)
html>
<body>
Use of the Struts iterate tag with nested ArrayLists representing
rows/cols:<p>
<%@ page import="java.util.ArrayList" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%
ArrayList rows = new ArrayList();
ArrayList rowOne = new ArrayList();
rowOne.add("bob");
rowOne.add("jones");
rowOne.add("bob@bob.com");
ArrayList rowTwo = new ArrayList();
rowTwo.add("ted");
rowTwo.add("Walters");
rowTwo.add("ted@ted.com");
ArrayList rowThree = new ArrayList();
rowThree.add("Mary");
rowThree.add("Smith");
rowThree.add("mary@mary.com");
rows.add(rowOne);
rows.add(rowTwo);
rows.add(rowThree);
request.setAttribute("DATASET",rows);
%>
<table border="1">
<logic:iterate id="eachRow" name="DATASET" scope="request">
<tr>
<logic:iterate id="eachCol" name="eachRow">
<td>
<bean:write name="eachCol" />
</td>
</logic:iterate>
</tr>
</logic:iterate>
</table>
</body>
</html>
Hope that helps.
-- Geoff
--
Sent via jApache.org
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>