If this is a money field, might I suggest that you not store it as a double, but instead store it as an int (for pennies) or some other accurate decimal encoding (BigDecimal comes to mind) so that you don't get annoying round-off errors that you might not expect.

If you choose an int, you can display it as

int/100 + "." + int%100

If you want to use BigDecimal or double, you can use a NumberFormat to correctly put in the right number of decimal places.

HTH,
Todd

On Apr 17, 2005, at 7:57 PM, Joshua Long wrote:

Hiya guys

Here is my (admittedly stupid) problem:

I have a field with a validator of

org.apache.tapestry.valid.NumberValidator

and a value type of 'double'  --
it shows a value of 1234.0 -- and what I need is 1234.00 -- I literally
need to set the precision of the case where the value has no decimal
values.

1234.22 stays and works just fine and updates my paramter just fine.

1234 renders as 1234.0  -- therein is the problem. It needs to be
1234.00 !

Customer is always right, I guess.. I'm sorry to even ask, but is there
an elegant way to solve this problem that I am missing short of writing
a custom
DoubleWithPrecisionValidator ?

Josh?



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to