Re: How to do matematical operation in jsp.

2009-04-22 Thread Andy Sykes
Abstract the HashMap behind another class that has a getTotal(Item key) method, and do the math in there (return item.prize * quantity). Doing any math in the JSP feels dirty. On 22 Apr 2009, at 13:16, Stefano Tranquillini wrote: Because the items are stored in hashmap item contains the p

Re: How to do matematical operation in jsp.

2009-04-22 Thread Stefano Tranquillini
Because the items are stored in hashmap item contains the prize. so, to know the total for each item i've to multplay item.prize with quantity. no more else. On Wed, Apr 22, 2009 at 14:01, Dave Newton wrote: > Stefano Tranquillini wrote: > >> but i've only to display in a jsp the results, wh

Re: How to do matematical operation in jsp.

2009-04-22 Thread Dave Newton
Stefano Tranquillini wrote: but i've only to display in a jsp the results, when i use that value i compute it by the ejb. Then why are you re-computing it in the JSP? The point is only that floating-point math is inaccurate. If you don't care, or are controlling the results of the math someho

Re: How to do matematical operation in jsp.

2009-04-22 Thread Stefano Tranquillini
but i've only to display in a jsp the results, when i use that value i compute it by the ejb. On Tue, Apr 21, 2009 at 22:51, Dave Newton wrote: > Stefano Tranquillini wrote: > >> The right solution is to calculate and insert in a new bean the elements >> and >> its total value? >> > > That's *a*

Re: How to do matematical operation in jsp.

2009-04-21 Thread Dave Newton
Stefano Tranquillini wrote: The right solution is to calculate and insert in a new bean the elements and its total value? That's *a* right solution, yes, particularly since you're doing money math. For money math to produce consistent, correct results you usually need to define a precision an

Re: How to do matematical operation in jsp.

2009-04-21 Thread Stefano Tranquillini
The right solution is to calculate and insert in a new bean the elements and its total value? On Tue, Apr 21, 2009 at 20:29, wrote: > Nice reference Wes! BTW, I noticed you are not using the new cover letter > for the TPS reports, so I'm going to have to go ahead and ask you to read > that memo

Re: How to do matematical operation in jsp.

2009-04-21 Thread stanlick
Nice reference Wes! BTW, I noticed you are not using the new cover letter for the TPS reports, so I'm going to have to go ahead and ask you to read that memo one more time. Peace, the Bob's On Tue, Apr 21, 2009 at 11:11 AM, Wes Wannemacher wrote: > [snip] > > > > OTOH, siphoning the $.

Re: How to do matematical operation in jsp.

2009-04-21 Thread Dave Newton
Lukasz Lenart wrote: 2009/4/21 Dave Newton : And the next step will be implement whole bank security in jsp :P Right, because that's clearly the type of "trivial functionality" I was talking about. Don't be ridiculous. Young programmers very often follow such advices and extend logic in jsp

Re: How to do matematical operation in jsp.

2009-04-21 Thread Stefano Tranquillini
works! On Tue, Apr 21, 2009 at 18:56, Lukasz Lenart wrote: > 2009/4/21 Dave Newton : > >>> And the next step will be implement whole bank security in jsp :P > > > Right, because that's clearly the type of "trivial functionality" I was > > talking about. Don't be ridiculous. > > Young programmer

Re: How to do matematical operation in jsp.

2009-04-21 Thread Lukasz Lenart
2009/4/21 Dave Newton : >>> And the next step will be implement whole bank security in jsp :P > Right, because that's clearly the type of "trivial functionality" I was > talking about. Don't be ridiculous. Young programmers very often follow such advices and extend logic in jsp, they have a probl

Re: How to do matematical operation in jsp.

2009-04-21 Thread Dave Newton
mitch gorman wrote: Lukasz Lenart wrote: And the next step will be implement whole bank security in jsp :P ... Right, because that's clearly the type of "trivial functionality" I was talking about. Don't be ridiculous. Don't teach people such a things, jsp is only for presentation! What w

Re: How to do matematical operation in jsp.

2009-04-21 Thread mitch gorman
Lukasz Lenart wrote: > 2009/4/21 Dave Newton : > >>> How do you want to test it? I know it's a simple case, but it's better >>> to have logic in one place. >>> >> As I said, I'm easily convinced in this particular case. >> >> OTOH, there are plenty of times when it's simply easier, quicke

Re: How to do matematical operation in jsp.

2009-04-21 Thread Lukasz Lenart
2009/4/21 Dave Newton : >> How do you want to test it? I know it's a simple case, but it's better >> to have logic in one place. > > As I said, I'm easily convinced in this particular case. > > OTOH, there are plenty of times when it's simply easier, quicker, and > clearer to just implement trivial

Re: How to do matematical operation in jsp.

2009-04-21 Thread mitch gorman
and remember, STAY AWAY FROM THE PATH OF EEVILLE! Jim Kiley wrote: > EVIL, wow, sounds serious. > > On Tue, Apr 21, 2009 at 12:02 PM, Lukasz Lenart < > lukasz.len...@googlemail.com> wrote: > > >> 2009/4/21 Suneel : >> >>> I'm not sure about this but can't you invoke a function in

Re: How to do matematical operation in jsp.

2009-04-21 Thread Dave Newton
Jim Kiley wrote: RoundingMode.SUPERMAN_III I've caffeinated my nose. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org

Re: How to do matematical operation in jsp.

2009-04-21 Thread Wes Wannemacher
[snip] > > OTOH, siphoning the $.0039079850466805510222911834716796875 into > offshore accounts will eventually make you rich. > > Dave "Expecting his 10% cut" Newton > [/snip] But, you have to be careful when moving the money into your own account... [quote] We're not just talking ab

Re: How to do matematical operation in jsp.

2009-04-21 Thread Jim Kiley
RoundingMode.SUPERMAN_III On Tue, Apr 21, 2009 at 12:07 PM, Dave Newton wrote: > Dave Newton wrote: > >> The issue for me would be that if this is money maths it should be using >> BigDecimal (or something), and I'm not sure what OGNL would do with the '*' >> operator. >> > > It would multiply th

Re: How to do matematical operation in jsp.

2009-04-21 Thread Dave Newton
Lukasz Lenart wrote: 2009/4/21 Dave Newton : Meh--for simple stuff like this I'm not as sure, although if we're talking about a line item in a invoice, it wouldn't take much to convince me. How do you want to test it? I know it's a simple case, but it's better to have logic in one place. As

Re: How to do matematical operation in jsp.

2009-04-21 Thread Dave Newton
Jim Kiley wrote: EVIL, wow, sounds serious. I just tested BigDecimal math in JSP/OGNL and the room started smelling like sulfur. Sure, it could have been the huevos rancheros, but I'm pretty sure it was the math in the JSP. Dave --

Re: How to do matematical operation in jsp.

2009-04-21 Thread Dave Newton
Dave Newton wrote: The issue for me would be that if this is money maths it should be using BigDecimal (or something), and I'm not sure what OGNL would do with the '*' operator. It would multiply the BigDecimals, but using a default MathContext, which may or may not give the results you reall

Re: How to do matematical operation in jsp.

2009-04-21 Thread Jim Kiley
EVIL, wow, sounds serious. On Tue, Apr 21, 2009 at 12:02 PM, Lukasz Lenart < lukasz.len...@googlemail.com> wrote: > 2009/4/21 Suneel : > > I'm not sure about this but can't you invoke a function in OGNL. I > > guess thats how the getText function works in ognl. Probably you can > > write a functi

Re: How to do matematical operation in jsp.

2009-04-21 Thread Lukasz Lenart
2009/4/21 Suneel : > I'm not sure about this but can't you invoke a function in OGNL. I > guess thats how the getText function works in ognl. Probably you can > write a function in your action like getResult and invoke it using > > Correct me if i'm wrong. Yes you can do that, but it's EVIL! DON'

Re: How to do matematical operation in jsp.

2009-04-21 Thread Lukasz Lenart
2009/4/21 Dave Newton : > Meh--for simple stuff like this I'm not as sure, although if we're talking > about a line item in a invoice, it wouldn't take much to convince me. How do you want to test it? I know it's a simple case, but it's better to have logic in one place. > The issue for me would

Re: How to do matematical operation in jsp.

2009-04-21 Thread Suneel
I'm not sure about this but can't you invoke a function in OGNL. I guess thats how the getText function works in ognl. Probably you can write a function in your action like getResult and invoke it using Correct me if i'm wrong. On Tue, Apr 21, 2009 at 10:34 AM, Stefano Tranquillini wrote: > Hi

Re: How to do matematical operation in jsp.

2009-04-21 Thread Dave Newton
Lukasz Lenart wrote: 2009/4/21 Stefano Tranquillini : how can i do that? Add method to class Item to do that, jsp isn't place for business logic Meh--for simple stuff like this I'm not as sure, although if we're talking about a line item in a invoice, it wouldn't take much to convince me.

Re: How to do matematical operation in jsp.

2009-04-21 Thread Dave Newton
Stefano Tranquillini wrote: and a value calculated at runtime that is a moltiplication of: and how can i do that? Does not work? Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands,

Re: How to do matematical operation in jsp.

2009-04-21 Thread Lukasz Lenart
2009/4/21 Stefano Tranquillini : > how can i do that? Add method to class Item to do that, jsp isn't place for business logic Regards -- Lukasz http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache

How to do matematical operation in jsp.

2009-04-21 Thread Stefano Tranquillini
Hi all i've a hashmap that contains object and a value(int). i would display all the value of the object: x and a value calculated at runtime that is a moltiplication of: and how can i do that? thanks -- Stefano