You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ca...@apache.org on 2007/03/06 09:59:38 UTC

svn commit: r515032 - /myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/validators.js

Author: cagatay
Date: Tue Mar  6 00:59:37 2007
New Revision: 515032

URL: http://svn.apache.org/viewvc?view=rev&rev=515032
Log:
Add script validator for LongRangeValidator

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/validators.js

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/validators.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/validators.js?view=diff&rev=515032&r1=515031&r2=515032
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/validators.js (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/validators.js Tue Mar  6 00:59:37 2007
@@ -44,4 +44,45 @@
 				}
 			}
 	}
+}
+
+tomahawk.LongRangeValidator = function(min,max) {
+
+	this.MAXIMUM_MESSAGE_ID = "javax.faces.validator.LongRangeValidator.MAXIMUM";
+	this.MINIMUM_MESSAGE_ID = "javax.faces.validator.LongRangeValidator.MINIMUM";
+	this.NOT_IN_RANGE_MESSAGE_ID = "javax.faces.validator.NOT_IN_RANGE";
+	this.TYPE_MESSAGE_ID = "javax.faces.validator.LongRangeValidator.TYPE";
+		
+	this.validateValue = function(facesContext,uiinput,value) {
+		if(value == null)
+			return;
+			
+		if (min != null && max != null)
+        {
+            if (value < min || value > max)
+            {
+            	var args = new Array(min,max,uiinput.id);
+	            var facesMessage = tomahawk.MessageUtils.getMessage(tomahawk.FacesMessage.SEVERITY_ERROR,this.NOT_IN_RANGE_MESSAGE_ID,args);
+	            throw new tomahawk.ValidatorException(facesMessage);
+            }
+        }
+        else if (min != null)
+        {
+            if (value < min)
+            {
+				var args = new Array(min,uiinput.id);
+	            var facesMessage = tomahawk.MessageUtils.getMessage(tomahawk.FacesMessage.SEVERITY_ERROR,this.MINIMUM_MESSAGE_ID,args);
+	            throw new tomahawk.ValidatorException(facesMessage);
+            }
+        }
+        else if (max != null)
+        {
+            if (value > max)
+            {
+                var args = new Array(max,uiinput.id);
+	            var facesMessage = tomahawk.MessageUtils.getMessage(tomahawk.FacesMessage.SEVERITY_ERROR,this.MAXIMUM_MESSAGE_ID,args);
+	            throw new tomahawk.ValidatorException(facesMessage);
+            }
+        }
+	}
 }