Falco Wockenfuß created TRINIDAD-2533:
-----------------------------------------
Summary: TrNumberFormat doesn't parse native Numbers without
Currency
Key: TRINIDAD-2533
URL: https://issues.apache.org/jira/browse/TRINIDAD-2533
Project: MyFaces Trinidad
Issue Type: Bug
Affects Versions: 2.0.0-beta-2
Environment: Oracle ADF
Reporter: Falco Wockenfuß
If you enter a Number in a Currency-Field with a decimal separator (other than
".") and without trailing currency symbol you get a parse Error.
Test Case - Type in JS Console:
var tr = new TrNumberConverter( null, "currency", "de_DE" );
tr.getAsObject( "20,50" ); // Parse Error
tr.getAsObject( "20,50 €" ); // Working
tr.getAsObject( "20" ); // Working
Cause:
The Method TrNumberFormat.prototype.removePrefixAndSuffix will fail, if not
both matching Prefix and Suffix for Positive or Negative are present. If only
one of both is present an exception is thrown and parsing fails.
Since the Prefix for positive Currency is "" (the empty string) it will always
match and try to find the matching suffix "€" or fail.
In the case of an exception the default parseFloat is used as a fallback, which
works for default english notation, so plain Numbers and using the dot as a
decimal separator will work.
Expected Behaviour and proposed Fix:
Entering a locale Numberformat without Currency Symbol should be parsed without
giving an error. The removePrefixAndSuffix Method should be more lenient and
also accept input without currency suffix.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)