You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by ma...@apache.org on 2006/11/06 08:20:41 UTC

svn commit: r471663 - /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js

Author: matzew
Date: Mon Nov  6 00:20:40 2006
New Revision: 471663

URL: http://svn.apache.org/viewvc?view=rev&rev=471663
Log:
TrRangeValidator overhaul

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js?view=diff&rev=471663&r1=471662&r2=471663
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js Mon Nov  6 00:20:40 2006
@@ -93,24 +93,30 @@
   label
 )
 {
-
-  // This should probably do more than call decimalParse!
-  // the following line is needed because what's being passed
-  // into the validator is a number, and _decimalParse expects a string.
-  numberString = "" + value;
-  try
+  string = "" + value;
+  numberValue = parseFloat(string);
+  
+  if(numberValue >= this._minValue && numberValue <= this._maxValue)
   {
-    return _decimalParse(numberString, 
-                       this._messages,
-                       this._maxPrecision,
-                       this._maxScale,
-                       this._maxValue,
-                       this._minValue,
-                       label);
+    return string;
   }
-  catch (e)
+  else
   {
-    throw new TrValidatorException(e.getFacesMessage());
+    if(numberValue>this._maxValue)
+    {
+      facesMessage = _createFacesMessage(this._messages[(TrNumberConverter.LV+ '_S')],
+                                       this._messages[TrNumberConverter.LV],
+                                        label,
+                                        string);
+    }
+    else
+    {
+      facesMessage = _createFacesMessage(this._messages[(TrNumberConverter.MV+ '_S')],
+                                       this._messages[TrNumberConverter.MV],
+                                        label,
+                                        string);
+    }
+    throw new TrConverterException(facesMessage);
   }
 }
 
@@ -139,9 +145,6 @@
 )
 {
 
-  // This should probably do more than call decimalParse!
-  // the following line is needed because what's being passed
-  // into the validator is a number, and _decimalParse expects a string.
   string = "" + value;
   length = string.length;
   
@@ -344,38 +347,37 @@
       if (sepIndex != -1)
       {
         integerDigits = sepIndex;
-        fractionDigits = numberString.length - sepIndex -1;
+        fractionDigits = parseInt(numberString.length - parseInt(sepIndex -1));
       }
       
       var messageKey;
-      
-      if ((maxValue != (void 0)) &&
+      if ((maxValue != null) &&
           (result  > maxValue))
       {
         messageKey = TrNumberConverter.LV;
       }
-      else if ((minValue != (void 0)) &&
+      else if ((minValue != null) &&
                (result  < minValue))
       {
         messageKey = TrNumberConverter.MV;
       }
-      else if ((maxPrecision != (void 0)) &&
+      else if ((maxPrecision != null) &&
                (integerDigits  > maxPrecision))
       {
         messageKey = TrNumberConverter.LID;
       }
-      else if ((maxScale != (void 0)) &&
+
+      else if ((maxScale != null) &&
                (fractionDigits  > maxScale))
       {
         messageKey = TrNumberConverter.LFD;
       }
 
-      if (messageKey != (void 0))
+      if (messageKey != null)
       {
         var messages = messages;
-        
-        if ((messages == (void 0)) ||
-            (messages[messageKey] == (void 0)))
+        if ((messages == null) ||
+            (messages[messageKey] == null))
           throw  new TrConverterException(null, null, "Conversion failed, but no appropriate message found");  // default error format
         else
         {