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 2012/03/07 20:43:07 UTC

svn commit: r1298063 - /myfaces/trinidad/branches/1.2.12.7.0-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js

Author: gcrawford
Date: Wed Mar  7 19:43:07 2012
New Revision: 1298063

URL: http://svn.apache.org/viewvc?rev=1298063&view=rev
Log:
TRINIDAD-2139 Client NumberConverter with type=percent ignores maxfractiondigits when formatting

Thanks to Yee-Wah

Modified:
    myfaces/trinidad/branches/1.2.12.7.0-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js

Modified: myfaces/trinidad/branches/1.2.12.7.0-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.7.0-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js?rev=1298063&r1=1298062&r2=1298063&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.7.0-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js (original)
+++ myfaces/trinidad/branches/1.2.12.7.0-branch/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js Wed Mar  7 19:43:07 2012
@@ -140,6 +140,7 @@ TrNumberFormat.prototype.setMaximumFract
     {
       this._minFractionDigits = this._maxFractionDigits;
     }
+    this._isMaxFractionDigitsSet  = true;     
   }
 } 
 
@@ -395,7 +396,15 @@ TrNumberFormat.prototype.currencyToStrin
 TrNumberFormat.prototype.percentageToString = function(number)
 {
   number = number * 100;
-  number = this.getRounded(number);
+  
+  // TRINIDAD-2139: getRounded calls Math.round() on number. Since number is
+  // multiplied by 100 before this call and later divided, the result will 
+  // have at most 2 fractional digits, regardless of the value of maxFractionDigits. 
+  // Hence, if maxFractionDigits is set, don't call this method and let 
+  // numberToString format the string appropriately. 
+  if (this._isMaxFractionDigitsSet == null)
+    number = this.getRounded(number);  
+  
   if (isNaN(number))
   {
     throw new TrParseException("not able to parse number");