The reason is that you are closing out the logic:iterate too soon!

Look at the code you have sent, the <logic:iterate ... ends with a "/>".

What you need, as you know, is

<logic:iterate id=... property=...>
  <!-- whatever -->
</logic:iterate>

Sri

-----Original Message-----
From: mech [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, February 13, 2003 9:45 AM
To: [EMAIL PROTECTED]
Subject: <logic:iterate> does not iterate more than once, although collection 
definitely contains more elements


Hi,

I have been using <logic:iterate> for quite a while, but now I'm stuck. Using Struts 
1.1b2 on Tomcat 4.1.18.

This code makes me crazy:

        <bean:size id="test" name="EditAccountForm" property="roles"/>
        <bean:write name="test"/>

        <logic:iterate id="userRoles" name="EditAccountForm" property="roles"/>got 
one</logic:iterate>


I have a form bean named "EditAccountForm" with a collection (ArrayList
behind) named "roles".

I've checked it with <bean:size>... The collection contains for example "four" items. 
I've checked it with editAccountForm.getRoles().size() in my business logic and Action 
class before putting the Collection into my form bean. But I only receive the first 
element... Why not all four??? I think I'm using <logic:iterate> as usual...?!


Strangly if I do this:

        <logic:iterate id="userRoles" name="EditAccountForm" property="roles"/ 
offset="0" length="1">
                <bean:write name="userRoles" property="roleName"/>
        </logic:iterate>
        <logic:iterate id="userRoles" name="EditAccountForm" property="roles"/ 
offset="1" length="1">
                <bean:write name="userRoles" property="roleName"/>
        </logic:iterate>
        <logic:iterate id="userRoles" name="EditAccountForm" property="roles"/ 
offset="2" length="1">
                <bean:write name="userRoles" property="roleName"/>
        </logic:iterate>
        <logic:iterate id="userRoles" name="EditAccountForm" property="roles"/ 
offset="3" length="1">
                <bean:write name="userRoles" property="roleName"/>
        </logic:iterate>


I correctly get all four different values. But I have to "iterate" step-by-step by 
increasing the offset! Actually the tag should do that for me ;-( Whatever I do, I get 
only one element, although there are more in my collection as I proved in several 
ways...

Any hints? What did I do wrong this time? Where's the bug? I believe I did everything 
as usual... 100 times it worked, but not this time...

Thx.
Michael


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


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

Reply via email to