You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Van Nguyen <vn...@ur.com> on 2006/11/10 20:56:25 UTC
iterate through two collections
Hi,
I have two ArrayList that I need to iterate through:
<logic:iterate id="line" indexId="indexId" name="collection1">
<bean:write name="line" />
// write info contained in collection2
// something like this... but not working??
<bean:write name="collection2[indexed]" />
</logic>
collection1 and collection2 will always have the same number of
records...
Any ideas?
Re: iterate through two collections
Posted by Uday Karrothi <ka...@gmail.com>.
sorry wrong thread reply
regards,
Uday Karrothi
On 11/10/06, Uday Karrothi <ka...@gmail.com> wrote:
>
> Even you ar settign all the values properly and getting the display
> accurately. I do not think the changes you made to the Collection( in terms
> of textboxes or checkboxes or Selections) will not reflect on the arrayList.
> Atleast I failed in doing so. There are other ways liek using multiboxes,
> indexing the properties etc.
>
> i hope that was useful. I could give you examples but I am not sure if I
> am addressing the problem right.
>
> regards,
> Uday Karrothi
>
> On 11/10/06, Ed Griebel <ed...@gmail.com> wrote:
> >
> > Try using <bean:write name="collection2[indexId]" />. indexId should
> > be replaced with 0, 1, 2, ... as it iterates and the underlying
> > BeanUtils will extract the n-th element from the collection. I don't
> > think this will if you are using an unsorted collection (set, map)
> > because they don't support get(int)
> >
> >
> > On 11/10/06, Van Nguyen <vn...@ur.com> wrote:
> > >
> > >
> > >
> > >
> > > Hi,
> > >
> > >
> > >
> > > I have two ArrayList that I need to iterate through:
> > >
> > >
> > >
> > > <logic:iterate id="line" indexId="indexId" name="collection1">
> > >
> > > <bean:write name="line" />
> > >
> > > // write info contained in collection2
> > >
> > > // something like this… but not working??
> > >
> > > <bean:write name="collection2[indexed]" />
> > >
> > > </logic>
> > >
> > >
> > >
> > > collection1 and collection2 will always have the same number of
> > records…
> > >
> > >
> > >
> > > Any ideas?
> > >
> > >
> > > United Rentals
> > > Consider it done.™
> > > 800-UR-RENTS
> > > unitedrentals.com
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
Re: iterate through two collections
Posted by Uday Karrothi <ka...@gmail.com>.
Even you ar settign all the values properly and getting the display
accurately. I do not think the changes you made to the Collection( in terms
of textboxes or checkboxes or Selections) will not reflect on the arrayList.
Atleast I failed in doing so. There are other ways liek using multiboxes,
indexing the properties etc.
i hope that was useful. I could give you examples but I am not sure if I am
addressing the problem right.
regards,
Uday Karrothi
On 11/10/06, Ed Griebel <ed...@gmail.com> wrote:
>
> Try using <bean:write name="collection2[indexId]" />. indexId should
> be replaced with 0, 1, 2, ... as it iterates and the underlying
> BeanUtils will extract the n-th element from the collection. I don't
> think this will if you are using an unsorted collection (set, map)
> because they don't support get(int)
>
>
> On 11/10/06, Van Nguyen <vn...@ur.com> wrote:
> >
> >
> >
> >
> > Hi,
> >
> >
> >
> > I have two ArrayList that I need to iterate through:
> >
> >
> >
> > <logic:iterate id="line" indexId="indexId" name="collection1">
> >
> > <bean:write name="line" />
> >
> > // write info contained in collection2
> >
> > // something like this… but not working??
> >
> > <bean:write name="collection2[indexed]" />
> >
> > </logic>
> >
> >
> >
> > collection1 and collection2 will always have the same number of records…
> >
> >
> >
> > Any ideas?
> >
> >
> > United Rentals
> > Consider it done.™
> > 800-UR-RENTS
> > unitedrentals.com
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: iterate through two collections
Posted by Ed Griebel <ed...@gmail.com>.
Try using <bean:write name="collection2[indexId]" />. indexId should
be replaced with 0, 1, 2, ... as it iterates and the underlying
BeanUtils will extract the n-th element from the collection. I don't
think this will if you are using an unsorted collection (set, map)
because they don't support get(int)
On 11/10/06, Van Nguyen <vn...@ur.com> wrote:
>
>
>
>
> Hi,
>
>
>
> I have two ArrayList that I need to iterate through:
>
>
>
> <logic:iterate id="line" indexId="indexId" name="collection1">
>
> <bean:write name="line" />
>
> // write info contained in collection2
>
> // something like this… but not working??
>
> <bean:write name="collection2[indexed]" />
>
> </logic>
>
>
>
> collection1 and collection2 will always have the same number of records…
>
>
>
> Any ideas?
>
>
> United Rentals
> Consider it done.™
> 800-UR-RENTS
> unitedrentals.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: iterate through two collections
Posted by Wendy Smoak <ws...@gmail.com>.
On 11/10/06, Van Nguyen <vn...@ur.com> wrote:
> I have two ArrayList that I need to iterate through:
> <logic:iterate id="line" indexId="indexId" name="collection1">
> <bean:write name="line" />
> // write info contained in collection2
> // something like this… but not working??
> <bean:write name="collection2[indexed]" />
> </logic>
>
> collection1 and collection2 will always have the same number of records…
That you need to do this probably means "two ArrayLists" is the wrong
data structure. How about a single array list of some object that has
two properties? Or a Map? I can't tell what you're doing from the
contrived example.
If you must do it, <logic:iterate> exposes the current index as
'indexId' which might help.
http://struts.apache.org/1.x/struts-taglib/tlddoc/logic/iterate.html
--
Wendy
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org