Aside from the various errors, I think the answer to your original question
is "you can't do that".

Let me see if I understand what you want to do. You have a Vector whose
elements are of some bean class (BuddyListForm I believe). You want to
iterate over that Vector. Then, for each object, you want to iterate over
its properties. So, for your BuddyListForm, the body of the iterator would
be evaluated once for each of 'name', 'alias' and 'phoneno'. Is this right?

The iterate tag does not support this. It operates on collections,
iterators, maps, and arrays of objects. It does not support on-the-fly
generation of such a collection using introspection on a bean, which is what
would be needed for what you want to do.

Hope this helps.

--
Martin Cooper


----- Original Message -----
From: "Sundar @eSaravana" <[EMAIL PROTECTED]>
To: "Jaganathan, Rupa" <[EMAIL PROTECTED]>; "Craig R.
McClanahan" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, March 24, 2001 6:34 PM
Subject: Re: Iterate Tag question, again --> Short ane sweet


> Hi,
>
> This is my situation:
> I have a collection(Vector) of buddyListForm as session attribute.
>
> So, in my JSP,
>
> <logic:iterate id="buddylist" property="buddylist" scope="session"> <!--
> vector being iterated -->
> <!--Now, I have the individual bean, how do I iterate the properties-->
> <logic:iterate  id="buddy" name="buddylist" scope="session">
> <tr>
>     <bean:write name= "buddy"  property="name" filter="true"/>
> </tr>
> </logic:iterate>
> </logic:iterate>
>
> All I get for this code is:
> javax.servlet.jsp.JspException: Cannot find bean buddy in scope null
> at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:212)
> at
>
org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:............
> .....
>
> I am attaching buddyListForm, too.
>
> Sundar
>
>
> ----- Original Message -----
> From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Friday, March 23, 2001 2:41 PM
> Subject: Re: Iterate Tag question, again --> Short ane sweet
>
>
> >
> >
> > On Fri, 23 Mar 2001, Sundar @eSaravana wrote:
> >
> > > Since nobody seemed to have read my long mail, I am re-writing my mail
> short
> > > and probably sweet.
> > >
> > > Can I do, multilevel iteration with iterate tag.?
> > > For example:
> > > I have collection of beans in my session. In my JSP, I want to first
> iterate
> > > at the collection to get the individual beans. And for every bean
again
> > > iterate to get attributes/variables.
> >
> > There is no current mechanism to iterate over the properties of a bean
> > (which is what I *think* you meant by attributes/variables).  However,
if
> > your bean had a method that returned all the interesting stuff as a Map
or
> > something like that, you could certainly have a nested iteration over
> > that.
> >
> > For example, consider a bean that has a getter method:
> >
> > public Map getProperties();
> >
> > and you had a collection of them called "beans".  Then you can:
> >
> > <logic:iterate id="bean" name="beans">
> >   Now processing bean <bean:write name="bean" property="id"/>
> >   <logic:iterate id="property" name="bean" property="properties">
> >     Property <bean:write name="property" property="key"/>
> >     has value <bean:write name="property" property="value"/>
> >   </logic:iterate>
> > </logic:iterate>
> >
> >
> > > Any help is deeply appreciated.
> > >
> > > Cheers.......................!
> > > Sundar
> > >
> > >
> >
> > Craig
> >
> >
>
>


Reply via email to