You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Milan Milanovic <mi...@yahoo.com> on 2008/06/05 16:36:18 UTC

[Struts 2] Iterator usage

Hi,

I have one question regarding iterator. I have one simple list that contain three values:
List { id, value, date } and I'm iterating through this list. And I want to show in my list a sum for value for every day at the last row that contain that date, like this:

id&nbsp;&nbsp;&nbsp; value&nbsp;&nbsp;&nbsp;&nbsp; date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum
----------------------------------------------------------
1&nbsp;&nbsp;&nbsp; 10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 20.5.2008
2&nbsp;&nbsp;&nbsp; 15 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 20.5.2008
3&nbsp;&nbsp;&nbsp; 15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 20.5.2008&nbsp;&nbsp;&nbsp; 40
4&nbsp;&nbsp;&nbsp; 12&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 21.5.2008
5&nbsp;&nbsp;&nbsp; 15 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 21.5.2008&nbsp;&nbsp;&nbsp; 27
6&nbsp;&nbsp;&nbsp; 12&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 22.5.2008
...

I'm now have done all iterating except this sum column. Do you have any ideas how efficent can I do this ?

--
Thx, Milan Milanovic



      

Re: [Struts 2] Iterator usage

Posted by Laurie Harper <la...@holoweb.net>.
I assume 'rearding interator' means the s:iterator tag in a JSP? I doubt 
there is any clean/sane way to do this from within the JSP. Instead, do 
the summation logic in the action and give the JSP a data structure that 
already includes this information.

L.

Milan Milanovic wrote:
> Hi,
> 
> I have one question regarding iterator. I have one simple list that contain three values:
> List
> { id, value, date } and I'm iterating through this list. And I want to
> show in my list a sum for value for every day at the last row that
> contain that date, like this:
> 
> id__value___date_______sum
> ----------------------------------------------------------
> 1__10_____20.5.2008
> 2__15_____20.5.2008
> 3__15_____20.5.2008___40
> 4__12_____21.5.2008
> 5__15_____21.5.2008___27
> 6__12_____22.5.2008
> ....
> 
> I'm now have done all iterating except this sum column. Do you have any ideas how efficent can I do this ?
> 
> --
> Thx, Milan Milanovic
> 
> 
> --- On Thu, 6/5/08, Milan Milanovic &lt;milanmilanovich@yahoo.com&gt; wrote:
> From: Milan Milanovic &lt;milanmilanovich@yahoo.com&gt;
> Subject: [Struts 2] Iterator usage
> To: user@struts.apache.org
> Date: Thursday, June 5, 2008, 7:36 AM
> 
> Hi,
> 
> I have one question regarding iterator. I have one simple list that contain
> three values:
> List { id, value, date } and I'm iterating through this list. And I want to
> show in my list a sum for value for every day at the last row that contain that
> date, like this:
> 
> id&amp;nbsp;&amp;nbsp;&amp;nbsp; value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
> date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
> sum
> ----------------------------------------------------------
> 1&amp;nbsp;&amp;nbsp;&amp;nbsp;
> 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
> 20.5.2008
> 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 15
> &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
> 20.5.2008
> 3&amp;nbsp;&amp;nbsp;&amp;nbsp;
> 15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
> 20.5.2008&amp;nbsp;&amp;nbsp;&amp;nbsp; 40
> 4&amp;nbsp;&amp;nbsp;&amp;nbsp;
> 12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
> 21.5.2008
> 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 15
> &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
> 21.5.2008&amp;nbsp;&amp;nbsp;&amp;nbsp; 27
> 6&amp;nbsp;&amp;nbsp;&amp;nbsp;
> 12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
> 22.5.2008
> ....
> 
> I'm now have done all iterating except this sum column. Do you have any
> ideas how efficent can I do this ?
> 
> --
> Thx, Milan Milanovic
> 
> 
>       


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [Struts 2] Iterator usage

Posted by Milan Milanovic <mi...@yahoo.com>.
Hi,

I have one question regarding iterator. I have one simple list that contain three values:
List
{ id, value, date } and I'm iterating through this list. And I want to
show in my list a sum for value for every day at the last row that
contain that date, like this:

id__value___date_______sum
----------------------------------------------------------
1__10_____20.5.2008
2__15_____20.5.2008
3__15_____20.5.2008___40
4__12_____21.5.2008
5__15_____21.5.2008___27
6__12_____22.5.2008
...

I'm now have done all iterating except this sum column. Do you have any ideas how efficent can I do this ?

--
Thx, Milan Milanovic


--- On Thu, 6/5/08, Milan Milanovic &lt;milanmilanovich@yahoo.com&gt; wrote:
From: Milan Milanovic &lt;milanmilanovich@yahoo.com&gt;
Subject: [Struts 2] Iterator usage
To: user@struts.apache.org
Date: Thursday, June 5, 2008, 7:36 AM

Hi,

I have one question regarding iterator. I have one simple list that contain
three values:
List { id, value, date } and I'm iterating through this list. And I want to
show in my list a sum for value for every day at the last row that contain that
date, like this:

id&amp;nbsp;&amp;nbsp;&amp;nbsp; value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
sum
----------------------------------------------------------
1&amp;nbsp;&amp;nbsp;&amp;nbsp;
10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
20.5.2008
2&amp;nbsp;&amp;nbsp;&amp;nbsp; 15
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
20.5.2008
3&amp;nbsp;&amp;nbsp;&amp;nbsp;
15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
20.5.2008&amp;nbsp;&amp;nbsp;&amp;nbsp; 40
4&amp;nbsp;&amp;nbsp;&amp;nbsp;
12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
21.5.2008
5&amp;nbsp;&amp;nbsp;&amp;nbsp; 15
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
21.5.2008&amp;nbsp;&amp;nbsp;&amp;nbsp; 27
6&amp;nbsp;&amp;nbsp;&amp;nbsp;
12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
22.5.2008
...

I'm now have done all iterating except this sum column. Do you have any
ideas how efficent can I do this ?

--
Thx, Milan Milanovic