You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gc...@apache.org on 2011/02/11 01:11:33 UTC
svn commit: r1069638 -
/myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js
Author: gcrawford
Date: Fri Feb 11 00:11:33 2011
New Revision: 1069638
URL: http://svn.apache.org/viewvc?rev=1069638&view=rev
Log:
TRINIDAD-1958 Client tr:numberConverter with type="currency" incorrectly handles arabic locale for positive values
Thanks to Yee-Wah for the patch
Modified:
myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js?rev=1069638&r1=1069637&r2=1069638&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js Fri Feb 11 00:11:33 2011
@@ -273,50 +273,38 @@ TrNumberFormat.prototype.stringToCurrenc
{
//is the string negative ?
var negP = numberString.indexOf(this._nPre);
-
- if(negP != -1)
+ var nSufNoSpace = this._nSuf;
+ if (nSufNoSpace.charAt(0) == ' ' || nSufNoSpace.charAt(0) == '\xa0')
+ nSufNoSpace = nSufNoSpace.substring(1);
+ var negS = numberString.indexOf(nSufNoSpace);
+
+
+ // TRINIDAD-1958: In Arabic the values for negPrefix and posPrefix are the same, so it is insufficient to test for
+ // the presence of (only) negPrefix to determine if the number is negative.
+ if(negP != -1 && negS != -1)
{
- numberString = numberString.substr(this._nPre.length, numberString.length);
- var nSufNoSpace = this._nSuf;
- if (nSufNoSpace.charAt(0) == ' ' || nSufNoSpace.charAt(0) == '\xa0')
- nSufNoSpace = nSufNoSpace.substring(1);
- var negS = numberString.indexOf(nSufNoSpace);
- if(negS != -1)
- {
- numberString = numberString.substr(0, numberString.length - nSufNoSpace.length);
- return (this.stringToNumber(numberString) * -1);
- }
- else
- {
- throw new TrParseException("not able to parse number");
- }
+ numberString = numberString.substr(this._nPre.length, numberString.length - (this._nPre.length + nSufNoSpace.length));
+ return (this.stringToNumber(numberString) * -1);
}
else
{
var posP = numberString.indexOf(this._pPre);
- if(posP != -1)
+ var pSufNoSpace = this._pSuf;
+ if (pSufNoSpace.charAt(0) == ' ' || pSufNoSpace.charAt(0) == '\xa0')
+ pSufNoSpace = pSufNoSpace.substring(1);
+ var posS = numberString.indexOf(pSufNoSpace);
+
+ if(posP != -1 && posS != -1)
{
- numberString = numberString.substr(this._pPre.length, numberString.length);
- var pSufNoSpace = this._pSuf;
- if (pSufNoSpace.charAt(0) == ' ' || pSufNoSpace.charAt(0) == '\xa0')
- pSufNoSpace = pSufNoSpace.substring(1);
- var posS = numberString.indexOf(pSufNoSpace);
- if(posS != -1)
- {
- numberString = numberString.substr(0, numberString.length - pSufNoSpace.length);
- numberString = this.stringToNumber(numberString);
- }
- else
- {
- throw new TrParseException("not able to parse number");
- }
+ numberString = numberString.substr (this._pPre.length, numberString.length - (this._pPre.length + pSufNoSpace.length));
+ numberString = this.stringToNumber(numberString);
return numberString;
}
else
{
- throw new TrParseException("not able to parse number");
- }
- }
+ throw new TrParseException("not able to parse number");
+ }//end-if we could not find a positive or negative prefix/suffix pair
+ }//end-if not negative
}
/**