horri khalid wrote:
Hi,
I have a logic:iterate block in my JSP file that needs to iterate over two
Collections (ArrayList) simultaneously. That is:
         <td  height="24" align="left" class="td_lst bld">Car</td>
            <td  height="24" align="left" class="td_lst bld">/km</td>
           <td  height="24" align="left" class="td_lst bld">/day</td>
          <logic:iterate id="car" name="Cars">
            <td  height="24" align="left" class="td_lst bld"><bean:write
name="car" property="name"/></td>
            <td  height="24" align="left" class="td_lst bld"><bean:write
name="rate" property="perkm"/></td>
           <td  height="24" align="left" class="td_lst bld"><bean:write
name="rate" property="perday"/></td>
         </logic:iterate>

Problem is, the "property" attribute in the <bean:write name="rate"
property="perkm"/> tag is in error (I put it in to try to describe what I am
trying to do.) In other words, my ActionForm class has two ArrayLists (Cars
and Rates) and I want to put a value from each in thos <td>s.

How do I code the iterate block? I can iterate over one property, but not
two. As you're no doubt aware, I'm pretty new to Struts.

Assuming you have a one-to-one correspondence between items in the 'cars' collection and items in the 'rates' collection, the easiest thing would probably be to zip both collections together into a single collection of beans encapsulating the data from cars and rates. You can then trivially iterate the single, combined collection. Or, depending on how your data is structured/retrieved, you may be able to just combine the two data structures so, for example, you have properties 'name', 'perkm' and 'perday' on each 'car' bean.

L.


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

Reply via email to