You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alex Colic <al...@pop-ware.com> on 2001/04/19 21:50:44 UTC

Need help with logic:iterate :)

Hi,

I am trying to get a handle on the logic:iterate tag.

I have an object in application scope under the key 'storeroomList.'
There is a vector of objects under the property 'storeroomList'. Each one of
the objects in this vector has a property 'name.'

What I am trying to do is go through the vector and print out the names. I
have attempted the below but the only storeroom name to be printed out to
the screen is the last storeroom. I traced the execution of the iterate
class and it looks to be getting the correct data, going through each
element of the vector and pulling out the name property and then looping
through all the elements without printing them to the screen and then the
bean:write is called.

Any help is as usual greatly appreciated.


Oh, bonus question.. Lets say I only wanted to print out a particular
storeroom. Iterate through the vector but only print the storeroom that had
the name "main."


<logic:iterate id="storerooms" name="storeroomList" scope="application"
property="storeroomList"/>
	<bean:write name="storerooms" property="name" /><BR>
</logic:iterate>


Regards

Alex


Re: Need help with logic:iterate :)

Posted by "Oldeboershuis, Simon" <si...@outermedia.de>.
Hi Alex,

see below
Alex Colic schrieb:
> 
> Hi,
> 
> I am trying to get a handle on the logic:iterate tag.
> 
> I have an object in application scope under the key 'storeroomList.'
> There is a vector of objects under the property 'storeroomList'. Each one of
> the objects in this vector has a property 'name.'
> 
> What I am trying to do is go through the vector and print out the names. I
> have attempted the below but the only storeroom name to be printed out to
> the screen is the last storeroom. I traced the execution of the iterate
> class and it looks to be getting the correct data, going through each
> element of the vector and pulling out the name property and then looping
> through all the elements without printing them to the screen and then the
> bean:write is called.
> 
> Any help is as usual greatly appreciated.
> 
> Oh, bonus question.. Lets say I only wanted to print out a particular
> storeroom. Iterate through the vector but only print the storeroom that had
> the name "main."
> 
> <logic:iterate id="storerooms" name="storeroomList" scope="application"
> property="storeroomList"/>
                          ^
You close the iterate tag by putting the ending "/" right in the start
tag. 
I had this problem several times. It is a pity that there is NO ERROR
message is generated
>         <bean:write name="storerooms" property="name" /><BR>
> </logic:iterate>
> 
> Regards
> 
> Alex