Grokbase Groups Struts user June 2007
FAQ
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.

--
HORRI Khalid
J2EE Developper
---------------------------------------------------------
PHONE: +(212)22897659
GSM : +(212)77763981

Search Discussions

  • Laurie Harper at Jun 15, 2007 at 9:35 pm

    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: user-unsubscribe@struts.apache.org
    For additional commands, e-mail: user-help@struts.apache.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriesstruts
postedJun 15, '07 at 4:07p
activeJun 15, '07 at 9:35p
posts2
users2
websitestruts.apache.org
irc#struts

2 users in discussion

Laurie Harper: 1 post Horri khalid: 1 post

People

Translate

site design / logo © 2022 Grokbase