Issue Details (XML | Word | Printable)

Key: TRINIDAD-1360
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Gabrielle Crawford
Reporter: Gabrielle Crawford
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
MyFaces Trinidad

error in doubleconverter

Created: 06/Jan/09 02:17 AM   Updated: 06/Jan/09 09:24 PM
Return to search
Component/s: Components
Affects Version/s: 1.2.10-core, 1.0.10-core
Fix Version/s: 1.0.11-core, 1.2.11-core

Time Tracking:
Not Specified

Resolution Date: 06/Jan/09 09:24 PM


 Description  « Hide
Doubleconverter ignores locale, so it just does this on the server

* getAsString() --> return Double.toString(((Number)value).doubleValue());
* getAsObject() --> return Double.valueOf(stringValue);

On the client it does something similar to the server for getAsString.

However on the client for getAsObject it's calling _decimalParse, which uses localeSymbols to parse, which means it's using locale specific formatting on the client to interpret the string to an object. The doubleconverter must be consistent, either it's using the locale to parse/format to/from a string on both the server and client, or it's not, but the hybrid approach it's using right now causes bugs.

If I change my language to German [de] and run this
     <af:inputText label="value"
               value="#{demoInputNumberSlider.numberValue}"/>

and then type in "4.5" and tab out, it's turning this into 45 in _decimalParse.

If I type in "4,5" it's interpreting this as 4.5 on the client and not showing an error. However the string '4,5' will cause an error on the server, and should therefore cause an error on the client.

So, if I have this, and I enter 4.5 it tells me I have an error, because it thinks the value is 45 and not 4.5!
 <tr:inputText value="#{clientValidation.double}" label="double converter">
                <tr:validateDoubleRange maximum="10.5" minimum="1.5"/>
              </tr:inputText>



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Matthias Weßendorf added a comment - 06/Jan/09 01:53 PM
I think the same is true for FloatConverter as well

Matthias Weßendorf added a comment - 06/Jan/09 02:12 PM
I think that respecting the decimal delimiter is fine, but for more fancy formating (e.g. grouping)
=> 1,234.05
one should use the real NumberConverter