client convertNumber truncates invalid number instead of throwing exception
---------------------------------------------------------------------------

                 Key: TRINIDAD-1537
                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1537
             Project: MyFaces Trinidad
          Issue Type: Bug
            Reporter: Cale Scholl


On the client, 123abc45 is truncated to 123, whereas it should throw an 
exception; the server throws an exception

The reason that 123abc45 is truncated to 123 is due to a native js function:
parseFloat("123abc45") returns 123.

For currency and percent, the number string is parsed using an instance of
NumberFormat, which calls parseFloat on the number string.

However, for the number type, _decimalParse applies some "js magic" before
calling parseFloat:

  // OK; it's non-empty.  Now, disallow exponential
  // notation, and then use some JS magic to exclude
  // non-numbers
  if ((numberString.indexOf('e') < 0) &&
      (numberString.indexOf('E') < 0) &&
      (((numberString * numberString) == 0) ||
       ((numberString / numberString) == 1)))

So if we want to rule out number strings like "123abc45" for currency and
percent, we simply need to apply the same "js magic" to the parsing functions
in NumberFormat:

  TrNumberFormat.prototype.stringToNumber
  TrNumberFormat.prototype.stringToCurrency
  TrNumberFormat.prototype.stringToPercentage

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to