You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marco Mistroni <mm...@waersystems.com> on 2004/03/02 17:18:30 UTC
calculating sum inside logic:iterate
Hi all,
I have a colletion of items that have a method called price.
I was wandering if I could calculate the total of all prices via struts
Tags rather than using java code...
Anyone has any ideas?
Thanx in advance and regards
marco
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: calculating sum inside logic:iterate
Posted by Mark Lowe <ma...@talk21.com>.
Depends how you've done things.
If your items are nested in a form (indexed/mapped proerties) you could
have a total that is calculated there. Thus no need to do it in an
action or a jsp.
On 2 Mar 2004, at 17:18, Marco Mistroni wrote:
> Hi all,
> I have a colletion of items that have a method called price.
> I was wandering if I could calculate the total of all prices via struts
> Tags rather than using java code...
>
> Anyone has any ideas?
>
> Thanx in advance and regards
> marco
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: calculating sum inside logic:iterate
Posted by Mark Lowe <ma...@talk21.com>.
I see what you're saying. But at the same time, if you wanted to
develop a shopping cart that you could plug onto any model. Then IMO
calculating in a web tier bean say an action form isn't the most evil
thing in the world.
I agree entirely that the total should be calculated in the model,
before say saving to the db. But I think there's a case for doing this
in the web-tier.
On 2 Mar 2004, at 17:39, Nick Wesselman wrote:
> Technically this seems to be a business method, logic that would be
> better handled in your model code. So for example you have a
> ShoppingCart class which has a getItems() method to get your
> collection of items and a getTotal() method to add their prices.
>
> Not the answer you're looking for I think but my 2 cents.
>
> Nick
>
> Marco Mistroni wrote:
>
>> Hi all,
>> I have a colletion of items that have a method called price.
>> I was wandering if I could calculate the total of all prices via
>> struts
>> Tags rather than using java code...
>>
>> Anyone has any ideas?
>>
>> Thanx in advance and regards
>> marco
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: calculating sum inside logic:iterate
Posted by Nick Wesselman <nw...@halleonard.com>.
Technically this seems to be a business method, logic that would be
better handled in your model code. So for example you have a
ShoppingCart class which has a getItems() method to get your collection
of items and a getTotal() method to add their prices.
Not the answer you're looking for I think but my 2 cents.
Nick
Marco Mistroni wrote:
>Hi all,
> I have a colletion of items that have a method called price.
>I was wandering if I could calculate the total of all prices via struts
>Tags rather than using java code...
>
>Anyone has any ideas?
>
>Thanx in advance and regards
> marco
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org