You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Yee-Wah Lee (JIRA)" <de...@myfaces.apache.org> on 2010/11/09 22:54:22 UTC

[jira] Commented: (TRINIDAD-1958) Client tr:numberConverter with type="currency" incorrectly handles arabic locale for positive values

    [ https://issues.apache.org/jira/browse/TRINIDAD-1958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12930301#action_12930301 ] 

Yee-Wah Lee commented on TRINIDAD-1958:
---------------------------------------

The locale files define the currency data using prefix and suffix for the currency, e.g. in the localeElements_en_US.js defines
CurrencyElements:["\xa4", "XXX", "\xa4", "", "-\xa4", ""], 

which is interpreted as [Currency Symbol, Currency Code, Positive Prefix, Positive Suffix, Negative Prefix, Negative Suffix]. See Locale.js#_getCurrency*. 

The following is currency data for some locales:
en_US:
positive prefix: $
positive suffix: "", empty string
negative prefix: ($
negative suffix:  )

For Hebrew (he_IL):
positive prefix: "", empty string
positive suffix: \u05e9\x22\u05d7
negative prefix: -
negative suffix: \u05e9\x22\u05d7

Arabic (ar_SA),  note the values for negative prefix and negative suffix
positive prefix:  \u0631.\u0633.\u200f
positive suffix:  "", empty string
negative prefix:  \u0631.\u0633.\u200f
negative suffix:  -

The client number converter assumes the negative prefix is in the front,and tests for that first. In the arabic case, the locale files define negative prefix the same as positive prefix so it goes into the first clause which additionally searches for the  negative suffix. Failing to find that, it throws a ParseException. 
TrNumberFormat.prototype.stringToCurrency = function(numberString)
{
  //is the string negative ?
  var negP = numberString.indexOf(this._nPre);
  
  if(negP != -1)
  {
    numberString = numberString.substr(this._nPre.length, numberString.length);
..
    if(negS != -1)
    {
     // parse thev alue
    }
    else
    {
      throw new TrParseException("not able to parse number");
    }
}

> Client tr:numberConverter with type="currency" incorrectly handles arabic locale for positive values
> ----------------------------------------------------------------------------------------------------
>
>                 Key: TRINIDAD-1958
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1958
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>          Components: Components
>    Affects Versions: 1.2.13-core 
>            Reporter: Yee-Wah Lee
>            Priority: Minor
>
> 1. Use the following jspx, binding the value of the inputText to a positive integer. 
>   <tr:inputText label="InputText Arabic" value="#{clientValidation.integer}" autoSubmit="true">
>           <tr:convertNumber type="currency" locale="ar_SA"/> 
>           </tr:inputText>
>           <tr:outputText value="Value submitted is #{clientValidation.integer}"/>
> 2. Run the jspx, it displays something like:
> 2ر.س.‏ 0
> 3. Modify just the numerical portion of the text and tab off: Get an Incorrect Format error
> Enter a currency in the same format as this example: ر.س.‏ 10,250

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