Daniel Perry wrote:
This works ok for that scenario, but what about if you need each item out of
the list? eg, to iterate through a list of names:

<logic:iterate name="names" id="name">
<tr><td><bean:write name="name"/></td></tr>
</logic:iterate>

Gives one column....

<tr><td>name1</td></tr>
<tr><td>name2</td></tr>
<tr><td>name3</td></tr>
<tr><td>name4</td></tr>

Is there an easy way to get:

<tr><td>name1</td><td>name2</td></tr>
<tr><td>name3</td><td>name4</td></tr>

The best I can come up with (shooting from the hip) is to create an intermediate bean which contains two properties, the column-1 value and the column-2 value. Populate each bean, put them in a list, then iterate over that list. Something like this:


------------------------------------------------------------
List names = new ArrayList();
int i = 1;
while (i<=numItems) {
    TwoColBean b = new TwoColBean();
    b.setCol1("name" + i++);
    b.setCol1("name" + i++);
    this.names.add(b);
}
...
<c:forEach items="${names} var="name" >
  <tr>
    <td><c:out value="${name.col1}"/></td>
    <td><c:out value="${name.col2}"/></td>
  </tr>
</c:forEach>
------------------------------------------------------------

Surely there must be a tag lib somewhere that offers this?

--
bOOyah


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



Reply via email to