>From: "Keith Morrell" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: Iterate over a bean full of beans?
>Date: Mon, 23 Apr 2001 17:12:57 +1200
>
>I have an issue where I want to iterate using a bean which has "child"
>beans (excuse the non-industry standard lingo!) and would appreciate
>some advice (sorry this is my third post today, but I have been
>struggling with this and a couple of other issues for days now..)
>
>The old code went something like:
>
><% Iterator it = Summary.getAccounts().iterator();
> if(it.hasNext())....
>
>... and then within this loop,
>
><% while( it.hasNext() )
>{
> AccountBean ab = (AccountBean) it.next();
> out.println( ab.getName();
> out.println( ab.getPhone();
>
>... etc...
>
>Any help etc would be appreciated...as i am not sure how to access the
>child bean properties etc from the main bean (which would control the
>iterate loop)
>
Here is what I am doing :
I have a Bean with a vector field...
public class SearchResult implements Serializable {
private Vector lots = new Vector();
... and a method returning an array of the vector's elements ...
public Lot[] getLots() {
Lot[] results = new Lot[lots.size()];
lots.copyInto(results);
return results;
}
In the JSP I can use the iterate tag as follow :
<logic:iterate id="lot" name="searchResult" property="lots">
...
<bean:write name="lot" property="number" filter="true"/>
...
</logic:iterate>
Hope this helps
Gael Laurans
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.