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/02/17 10:37:28 UTC

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

Author: cagatay
Date: Sat Feb 17 01:37:28 2007
New Revision: 508747

URL: http://svn.apache.org/viewvc?view=rev&rev=508747
Log:
Fix mixed location of converters/validators

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/converters.js
    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/converters.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/converters.js?view=diff&rev=508747&r1=508746&r2=508747
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/converters.js (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/converters.js Sat Feb 17 01:37:28 2007
@@ -16,32 +16,27 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-tomahawk.LengthValidator = function(min,max) {
+tomahawk.IntegerConverter = function() {
 		
-	this.MAXIMUM_MESSAGE_ID = "javax.faces.validator.LengthValidator.MAXIMUM";
-	this.MINIMUM_MESSAGE_ID = "javax.faces.validator.LengthValidator.MINIMUM";
-		
-	this.validateValue = function(facesContext,uiinput,value) {
+	this.CONVERSION_MESSAGE_ID = "javax.faces.convert.IntegerConverter.CONVERSION";
 
-		if( value == null )
-			return;
+	this.getAsObject = function(context,uiinput,value) {
 		
-			var length = value.length;
-				
-			if(min != null) {
-				if(length < 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 );
+		if( value != null ) {
+			//TODO trim
+			if( value.length > 0)  {
+				var integerRegExp = /(^-?\d\d*$)/;
+				var isInteger = integerRegExp.test(value);						
+				if( !isInteger ) {
+					var facesMessage = tomahawk.MessageUtils.getMessage(tomahawk.FacesMessage.SEVERITY_ERROR,this.CONVERSION_MESSAGE_ID,new Array(uiinput.id,value))
+					throw new tomahawk.ConverterException( facesMessage );
 				}
-			}
-			
-			if(max != null) {
-				if(length> 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 );
+				else {
+					var convertedValue = parseInt( value );
+					return convertedValue;
 				}
 			}
+		}
+		return null;
 	}
 }

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=508747&r1=508746&r2=508747
==============================================================================
--- 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 Sat Feb 17 01:37:28 2007
@@ -16,27 +16,32 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-tomahawk.IntegerConverter = function() {
+tomahawk.LengthValidator = function(min,max) {
 		
-	this.CONVERSION_MESSAGE_ID = "javax.faces.convert.IntegerConverter.CONVERSION";
+	this.MAXIMUM_MESSAGE_ID = "javax.faces.validator.LengthValidator.MAXIMUM";
+	this.MINIMUM_MESSAGE_ID = "javax.faces.validator.LengthValidator.MINIMUM";
+		
+	this.validateValue = function(facesContext,uiinput,value) {
 
-	this.getAsObject = function(context,uiinput,value) {
+		if( value == null )
+			return;
 		
-		if( value != null ) {
-			//TODO trim
-			if( value.length > 0)  {
-				var integerRegExp = /(^-?\d\d*$)/;
-				var isInteger = integerRegExp.test(value);						
-				if( !isInteger ) {
-					var facesMessage = tomahawk.MessageUtils.getMessage(tomahawk.FacesMessage.SEVERITY_ERROR,this.CONVERSION_MESSAGE_ID,new Array(uiinput.id,value))
-					throw new tomahawk.ConverterException( facesMessage );
+			var length = value.length;
+				
+			if(min != null) {
+				if(length < 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 {
-					var convertedValue = parseInt( value );
-					return convertedValue;
+			}
+			
+			if(max != null) {
+				if(length> 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 );
 				}
 			}
-		}
-		return null;
 	}
 }