Hi All,

i am facing (sic!) a problem with faces and decimal numbers. i know this is not a trinidad specific problem, but maybe it should be taken into consideration:

The trinidad NumberConverter.getAsObject() method converts all Numbers to a java.lang.Number Object. (NumberConverter.java, line 226: Number num = (Number) fmt.parseObject(value,pp);)

I use this the following facelets code to enter prices for invoices:

<tr:inputText value="${item.price}"
 columns="7" required="true" contentStyle="direction: rtl;">
 <f:convertNumber maxFractionDigits="4" minFractionDigits="2" />
</tr:inputText>

I have read, that the trinidad converter replaces the standard convertNumber implementation, so <f:convertNumber should be the trinidad implementation...

The value binding ${item.price} is bound to a BigDecimal Object.

If i enter 29,95 (german locale) in the inputText field, the number gets converted to: "29.949999999999999289457264239899814128875732421875"

I know, this is a known problem on all computers, since numbers are calculated with integer fractions. But since Java has the BigDecimal object, isn't it useful to use it in the trinidad NumberConverter implementation? Maybe one can detect that the binding leads to a big decimal object and use then another method to parse the string?

If you say this is useful, i will try to contribute a patch. Or if someone has another solution i would be thankful to hear from it.

Regards
Felix Gonschorek

Reply via email to