You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Struts Newsgroup (@Basebeans.com)" <st...@basebeans.com> on 2002/06/02 16:25:02 UTC

a newbie question on iterate

Subject: a newbie question on iterate
From: "Gary Tam" <ga...@rogers.com>
 ===
Hi, I am trying to use iterate to display a collection on a jsp, are there
any simple example out there?  I tried to follow the examples with STRUTS,
but got all confuse.  Do I have to store the collection in a java bean ?  Is
this a collection of java beans or simple value objects? etc...  Can someone
please set me straight please

TIA
Gary



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: a newbie question on iterate

Posted by Tim Sawyer <ts...@nildram.co.uk>.
Use an action to put an object that implements Iterator interface into
session memory, and then in the JSP, your <logic:iterate> tag refers to
the name that you put the object in session memory under.

This code will cycle through the objects in the Iterator returned by
usersList.getMyIterator() and run getUserid() on each object returned,
displaying the results from each in a table.  element is a local
variable each time around the loop.  usersList is just a java class in
session memory, under the name "usersList"

<table>
<logic:iterate id="element" name="usersList" property="myIterator">
  <tr>
    <td width="10%" class="data"><bean:write name="element"
property="userid"/></td>
  </tr>  
</logic:iterate>
</table>

hth,

Tim.

On Sun, 2002-06-02 at 14:25, Struts Newsgroup wrote:
> Subject: a newbie question on iterate
> From: "Gary Tam" <ga...@rogers.com>
>  ===
> Hi, I am trying to use iterate to display a collection on a jsp, are there
> any simple example out there?  I tried to follow the examples with STRUTS,
> but got all confuse.  Do I have to store the collection in a java bean ?  Is
> this a collection of java beans or simple value objects? etc...  Can someone
> please set me straight please
> 
> TIA
> Gary
> 
> 
> 
> --
> 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>