You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/06/17 00:14:27 UTC

svn commit: r668332 [1/2] - in /myfaces/tomahawk/trunk: core/ core/src/main/java/org/apache/myfaces/custom/creditcardvalidator/ core/src/main/java/org/apache/myfaces/custom/equalvalidator/ core/src/main/java/org/apache/myfaces/custom/regexprvalidator/ ...

Author: lu4242
Date: Mon Jun 16 15:14:26 2008
New Revision: 668332

URL: http://svn.apache.org/viewvc?rev=668332&view=rev
Log:
TOMAHAWK-1285 Add validator property generation using abstract pattern like components using myfaces-builder-plugin

Added:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/creditcardvalidator/AbstractCreditCardValidator.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/AbstractEqualValidator.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/regexprvalidator/AbstractRegExprValidator.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/resources/META-INF/validatorClass11.vm
    myfaces/tomahawk/trunk/core12/src/main/resources/META-INF/validatorClass12.vm
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/AbstractCompareToValidator.java   (with props)
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/AbstractCSVValidator.java   (with props)
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/AbstractUrlValidator.java   (with props)
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/validatorClass11.vm
    myfaces/tomahawk/trunk/sandbox/core12/src/main/resources/META-INF/validatorClass12.vm
Removed:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/creditcardvalidator/CreditCardValidator.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/EqualValidator.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/regexprvalidator/RegExprValidator.java
    myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/custom/regexprvalidator/
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/CompareToValidator.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/CSVValidator.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/UrlValidator.java
    myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/comparetovalidator/
Modified:
    myfaces/tomahawk/trunk/core/pom.xml
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/stylesheet/TextResourceFilter.java
    myfaces/tomahawk/trunk/core/src/main/resources/META-INF/tagValidatorClass11.vm
    myfaces/tomahawk/trunk/core12/pom.xml
    myfaces/tomahawk/trunk/core12/src/main/resources/META-INF/tagValidatorClass12.vm
    myfaces/tomahawk/trunk/sandbox/core/pom.xml
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/componentClass11.vm
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagValidatorClass11.vm
    myfaces/tomahawk/trunk/sandbox/core12/pom.xml
    myfaces/tomahawk/trunk/sandbox/core12/src/main/resources/META-INF/tagValidatorClass12.vm
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/validateUrl.jsp

Modified: myfaces/tomahawk/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/pom.xml?rev=668332&r1=668331&r2=668332&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/pom.xml (original)
+++ myfaces/tomahawk/trunk/core/pom.xml Mon Jun 16 15:14:26 2008
@@ -307,7 +307,13 @@
             <goals>
               <goal>make-components</goal>
             </goals>
-          </execution>          
+          </execution>
+          <execution>
+            <id>makeval</id>
+            <goals>
+              <goal>make-validators</goal>
+            </goals>
+          </execution>
           <execution>
             <id>make_tags_myfaces_core</id>
             <configuration>

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/creditcardvalidator/AbstractCreditCardValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/creditcardvalidator/AbstractCreditCardValidator.java?rev=668332&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/creditcardvalidator/AbstractCreditCardValidator.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/creditcardvalidator/AbstractCreditCardValidator.java Mon Jun 16 15:14:26 2008
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.creditcardvalidator;
+
+import org.apache.myfaces.validator.ValidatorBase;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.ValidatorException;
+
+/**
+ * A custom validator for creditCards, based upon Jakarta Commons. 
+ * 
+ * Unless otherwise specified, all attributes accept static values or EL expressions
+ * 
+ * @JSFValidator
+ *   name = "t:validateCreditCard"
+ *   class = "org.apache.myfaces.custom.creditcardvalidator.CreditCardValidator"
+ *   bodyContent = "empty"
+ *   tagClass = "org.apache.myfaces.custom.creditcardvalidator.ValidateCreditCardTag"
+ *   serialuidtag = "3810660506302799072L"
+ * 
+ * @author mwessendorf (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public abstract class AbstractCreditCardValidator extends ValidatorBase {
+
+	/**
+	 * <p>The standard converter id for this converter.</p>
+	 */
+	public static final String 	VALIDATOR_ID 	   = "org.apache.myfaces.validator.CreditCard";
+
+	/**
+	 * <p>The message identifier of the {@link FacesMessage} to be created if
+	 * the creditcard check fails.</p>
+	 */
+	public static final String CREDITCARD_MESSAGE_ID = "org.apache.myfaces.Creditcard.INVALID";
+
+	public AbstractCreditCardValidator(){
+	}
+
+	//Field, to init the desired Validator
+	private int _initSum = 0;
+
+	private org.apache.commons.validator.CreditCardValidator creditCardValidator = null;
+
+	/**
+	 *
+	 */
+	public void validate(
+		FacesContext facesContext,
+		UIComponent uiComponent,
+		Object value)
+		throws ValidatorException {
+
+			if (facesContext == null) throw new NullPointerException("facesContext");
+			if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+			if (value == null)
+			{
+				return;
+			}
+		initValidator();
+		if (!this.creditCardValidator.isValid(value.toString())){
+			Object[] args = {value.toString()};
+            throw new ValidatorException(getFacesMessage(CREDITCARD_MESSAGE_ID, args));
+		}
+	}
+
+
+	// -------------------------------------------------------- Private Methods
+
+	/**
+	 * <p>initializes the desired validator.</p>
+	 */
+
+	private void initValidator() {
+		if(isNone()){
+			//no cardtypes are allowed
+			creditCardValidator = new org.apache.commons.validator.CreditCardValidator(org.apache.commons.validator.CreditCardValidator.NONE);
+		}
+		else{
+			computeValidators();
+			creditCardValidator = new org.apache.commons.validator.CreditCardValidator(_initSum);
+		}
+	}
+
+	/**
+	 * private methode, that counts the desired creditCards
+	 */
+	private void computeValidators(){
+		if(isAmex()){
+			this._initSum= org.apache.commons.validator.CreditCardValidator.AMEX + _initSum;
+		}
+		if(isVisa()){
+			this._initSum= org.apache.commons.validator.CreditCardValidator.VISA+ _initSum;
+		}
+		if(isMastercard()){
+			this._initSum= org.apache.commons.validator.CreditCardValidator.MASTERCARD+ _initSum;
+		}
+		if(isDiscover()){
+			this._initSum= org.apache.commons.validator.CreditCardValidator.DISCOVER+ _initSum;
+		}
+	}
+
+	//GETTER & SETTER
+	
+	/**
+	 * american express cards
+	 * 
+	 * @JSFProperty
+	 *   defaultValue = "true"
+	 */
+	public abstract boolean isAmex();
+
+    /**
+     * validation for discover
+     * 
+     * @JSFProperty
+     *   defaultValue = "true"
+     */
+	public abstract boolean isDiscover();
+
+    /**
+     * validation for mastercard
+     * 
+     * @JSFProperty
+     *   defaultValue = "true"
+     */
+	public abstract boolean isMastercard();
+
+    /**
+     * none of the given cardtypes is allowed.
+     * 
+     * @JSFProperty
+     *   defaultValue = "false"
+     */
+	public abstract boolean isNone();
+
+    /**
+     * validation for visa
+     * 
+     * @JSFProperty
+     *   defaultValue = "true"
+     */
+	public abstract boolean isVisa();
+
+	public abstract void setAmex(boolean b);
+
+	public abstract void setDiscover(boolean b);
+
+	public abstract void setMastercard(boolean b);
+
+	public abstract void setNone(boolean b);
+
+	public abstract void setVisa(boolean b);
+
+}

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/creditcardvalidator/AbstractCreditCardValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/creditcardvalidator/AbstractCreditCardValidator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/AbstractEqualValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/AbstractEqualValidator.java?rev=668332&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/AbstractEqualValidator.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/AbstractEqualValidator.java Mon Jun 16 15:14:26 2008
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.equalvalidator;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.el.ValueBinding;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.Renderer;
+import javax.faces.validator.ValidatorException;
+
+import org.apache.myfaces.validator.ValidatorBase;
+
+
+/**
+ * A custom validator for validations against foreign component values. 
+ * 
+ * Unless otherwise specified, all attributes accept static values or EL expressions.
+ * 
+ * @JSFValidator
+ *   name = "t:validateEqual"
+ *   class = "org.apache.myfaces.custom.equalvalidator.EqualValidator"
+ *   tagClass = "org.apache.myfaces.custom.equalvalidator.ValidateEqualTag"
+ *   serialuidtag = "-3249115551944863108L"
+ *   
+ * @author mwessendorf (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public abstract class AbstractEqualValidator extends ValidatorBase {
+
+	/**
+	 * <p>The standard converter id for this converter.</p>
+	 */
+	public static final String 	VALIDATOR_ID 	   = "org.apache.myfaces.validator.Equal";
+
+	/**
+	 * <p>The message identifier of the {@link FacesMessage} to be created if
+	 * the equal_for check fails.</p>
+	 */
+	public static final String EQUAL_MESSAGE_ID = "org.apache.myfaces.Equal.INVALID";
+
+	public AbstractEqualValidator(){
+	}
+
+  // -------------------------------------------------------- ValidatorIF
+	public void validate(
+		FacesContext facesContext,
+		UIComponent uiComponent,
+		Object value)
+		throws ValidatorException {
+
+	    if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+		if (value == null)
+		{
+		    return;
+		}
+
+        UIComponent foreignComp = uiComponent.getParent().findComponent(getFor());
+        if(foreignComp==null)
+            throw new FacesException("Unable to find component '" + getFor() + "' (calling findComponent on component '" + uiComponent.getId() + "')");
+        if(false == foreignComp instanceof EditableValueHolder)
+            throw new FacesException("Component '" + foreignComp.getId() + "' does not implement EditableValueHolder");
+        EditableValueHolder foreignEditableValueHolder = (EditableValueHolder) foreignComp;
+
+        if (foreignEditableValueHolder.isRequired() && foreignEditableValueHolder.getValue()== null ) {
+            return;
+        }
+        
+        Object foreignValue;
+        if (foreignEditableValueHolder.isValid())
+        {
+            foreignValue = foreignEditableValueHolder.getValue();
+        }
+        else
+        {
+            try 
+            {
+                foreignValue = getConvertedValueNonValid(facesContext, foreignComp);
+            }
+            catch(ConverterException e)
+            {
+                /*
+                 * If the value cannot be converted this should return,
+                 * because does not have sense compare one
+                 * foreign invalid value with other value.
+                 * this force end the validation but do not continue
+                 * with the next phases, because the converter
+                 * of the foreign component fails and show a validation error.
+                 */
+                return;
+            }
+        }
+
+        // Don't perform validation if the foreign value is null
+        if (null == foreignValue)
+        {
+            return;
+        }
+        
+
+		Object[] args = {value.toString(),(foreignValue==null) ? foreignComp.getId():foreignValue.toString()};
+
+		if(foreignEditableValueHolder.getValue()==null || !foreignValue.toString().equals(value.toString())  )
+        {
+            throw new ValidatorException(getFacesMessage(EQUAL_MESSAGE_ID, args));
+        }
+
+	}
+    
+    // ---------------- Borrowed to convert foreign submitted values
+
+    protected Renderer getRenderer(FacesContext context, UIComponent foreignComponent)
+    {
+        if (context == null) throw new NullPointerException("context");
+        String rendererType = foreignComponent.getRendererType();
+        if (rendererType == null) return null;
+        String renderKitId = context.getViewRoot().getRenderKitId();
+        RenderKitFactory rkf = (RenderKitFactory)FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+        RenderKit renderKit = rkf.getRenderKit(context, renderKitId);
+        Renderer renderer = renderKit.getRenderer(foreignComponent.getFamily(), rendererType);
+        if (renderer == null)
+        {
+            getFacesContext().getExternalContext().log("No Renderer found for component " + foreignComponent + " (component-family=" + foreignComponent.getFamily() + ", renderer-type=" + rendererType + ")");
+        }
+        return renderer;
+    }
+
+    protected Converter findUIOutputConverter(FacesContext facesContext, UIComponent component)
+    {
+        Converter converter = ((EditableValueHolder)component).getConverter();
+        if (converter != null) return converter;
+
+        //Try to find out by value binding
+        ValueBinding vb = component.getValueBinding("value");
+        if (vb == null) return null;
+
+        Class valueType = vb.getType(facesContext);
+        if (valueType == null) return null;
+
+        if (String.class.equals(valueType)) return null;    //No converter needed for String type
+        if (Object.class.equals(valueType)) return null;    //There is no converter for Object class
+
+        try
+        {
+            return facesContext.getApplication().createConverter(valueType);
+        }
+        catch (FacesException e)
+        {
+            getFacesContext().getExternalContext().log("No Converter for type " + valueType.getName() + " found", e);
+            return null;
+        }
+    }
+
+
+    // --------------------- borrowed and modified from UIInput ------------
+
+    protected Object getConvertedValueNonValid(FacesContext facesContext, UIComponent component)
+        throws ConverterException
+    {
+        Object componentValueObject;
+        Object submittedValue = ((EditableValueHolder) component).getSubmittedValue();
+        if (submittedValue == null)
+        {
+            componentValueObject = null;
+        }
+        else
+        {
+            Renderer renderer = getRenderer(facesContext, component);
+            if (renderer != null)
+            {
+                componentValueObject = renderer.getConvertedValue(facesContext, component, submittedValue);
+            }
+            else if (submittedValue instanceof String)
+            {
+                Converter converter = findUIOutputConverter(facesContext, component);
+                if (converter != null)
+                {
+                    componentValueObject = converter.getAsObject(facesContext, component, (String)submittedValue);
+                }
+                else
+                {
+                    componentValueObject = submittedValue;
+                }
+            }else{
+                componentValueObject = submittedValue;
+            }
+        }
+        return componentValueObject;
+    }
+        
+	// -------------------------------------------------------- GETTER & SETTER
+
+	/**
+	 * the id of the foreign component, which is needed for the validation
+	 * 
+	 * @JSFProperty
+	 * @return the foreign component_id, on which a value should be validated
+	 */
+	public abstract String getFor();
+
+	/**
+	 * @param string the foreign component_id, on which a value should be validated
+	 */
+	public abstract void setFor(String string);
+}

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/AbstractEqualValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/AbstractEqualValidator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/regexprvalidator/AbstractRegExprValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/regexprvalidator/AbstractRegExprValidator.java?rev=668332&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/regexprvalidator/AbstractRegExprValidator.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/regexprvalidator/AbstractRegExprValidator.java Mon Jun 16 15:14:26 2008
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.regexprvalidator;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.ValidatorException;
+
+import org.apache.commons.validator.GenericValidator;
+import org.apache.myfaces.validator.ValidatorBase;
+
+/**
+ * A custom validator for reg. expr., based upons Jakarta Commons. 
+ * 
+ * Unless otherwise specified, all attributes accept static values or EL expressions.
+ * 
+ * @JSFValidator
+ *   name = "t:validateRegExpr"
+ *   class = "org.apache.myfaces.custom.regexprvalidator.RegExprValidator"
+ *   tagClass = "org.apache.myfaces.custom.regexprvalidator.ValidateRegExprTag"
+ *   serialuidtag = "-449945949876262076L"
+ * 
+ * @author mwessendorf (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public abstract class AbstractRegExprValidator extends ValidatorBase {
+	/**
+	 * <p>The standard converter id for this converter.</p>
+	 */
+	public static final String 	VALIDATOR_ID 	   = "org.apache.myfaces.validator.RegExpr";
+
+	/**
+	 * <p>The message identifier of the {@link FacesMessage} to be created if
+	 * the regex check fails.</p>
+	 */
+	public static final String REGEXPR_MESSAGE_ID = "org.apache.myfaces.Regexpr.INVALID";
+
+	public AbstractRegExprValidator(){
+	}
+
+	public void validate(
+		FacesContext facesContext,
+		UIComponent uiComponent,
+		Object value)
+		throws ValidatorException {
+
+		if (facesContext == null) throw new NullPointerException("facesContext");
+		if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+		if (value == null)
+			{
+				return;
+		}
+		Object[] args = {value.toString()};
+		if(!GenericValidator.matchRegexp(value.toString(),"^"+getPattern()+"$")){
+			throw new ValidatorException(getFacesMessage(REGEXPR_MESSAGE_ID, args));
+        }
+	}
+
+	// -------------------------------------------------------- GETTER & SETTER
+
+	/**
+	 * the pattern, which is the base of the validation
+	 * 
+	 * @JSFProperty
+	 * @return the pattern, on which a value should be validated
+	 */
+    public abstract String getPattern();
+
+	/**
+	 * @param string the pattern, on which a value should be validated
+	 */
+	public abstract void setPattern(String string);
+
+}

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/regexprvalidator/AbstractRegExprValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/regexprvalidator/AbstractRegExprValidator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/stylesheet/TextResourceFilter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/stylesheet/TextResourceFilter.java?rev=668332&r1=668331&r2=668332&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/stylesheet/TextResourceFilter.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/stylesheet/TextResourceFilter.java Mon Jun 16 15:14:26 2008
@@ -154,7 +154,10 @@
 			return filteredResource;
 		}
 
-		String text = RendererUtils.loadResourceFile(context, path);
+		//Tomcat ASF Bugzilla – Bug 43241
+		//ServletContext.getResourceAsStream() does not follow API spec
+		//ALL resources must start with '/' 
+		String text = RendererUtils.loadResourceFile(context,'/' + path);
 		if (text == null)
 		{
 			// avoid loading the errorneous resource over and over again

Modified: myfaces/tomahawk/trunk/core/src/main/resources/META-INF/tagValidatorClass11.vm
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/META-INF/tagValidatorClass11.vm?rev=668332&r1=668331&r2=668332&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/META-INF/tagValidatorClass11.vm (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/META-INF/tagValidatorClass11.vm Mon Jun 16 15:14:26 2008
@@ -66,6 +66,15 @@
 #set ($className = $utils.getPrimitiveType($property.className))
         if ($field != null)
         {
+#if ($property.isLiteralOnly())
+#if ($utils.isPrimitiveClass($property.className))
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf($field).${property.className}Value());
+#elseif ($utils.isPrimitiveClass($className))
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf($field));
+#else
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}($field);
+#end
+#else
             if (UIComponentTag.isValueReference($field))
             {
                 ValueBinding vb = facesContext.getApplication().createValueBinding($field);
@@ -89,6 +98,7 @@
                 validator.${utils.getPrefixedPropertyName("set",$property.name)}($field);
 #end
             }
+#end
         }
 #end
         return validator;

Added: myfaces/tomahawk/trunk/core/src/main/resources/META-INF/validatorClass11.vm
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/META-INF/validatorClass11.vm?rev=668332&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/META-INF/validatorClass11.vm (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/META-INF/validatorClass11.vm Mon Jun 16 15:14:26 2008
@@ -0,0 +1,216 @@
+## Velocity template used to generate JSF1.1-compatible validator classes
+## from validator meta-data.
+##
+## Note that there are only one type of validator generation:
+##  * "subclass mode" (use annotated class as a parent class)
+##
+## Variable $validator refers to a ComponentMeta object to process
+## Variable $utils refers to an instance of MyfacesUtils.
+##
+## When "template mode" is being used then variable $innersource
+## holds a String containing all the non-abstract functions defined
+## in the annotated class.
+##
+## The java package of the generated class is always the same as
+## the package in which the annotated class exists.
+##
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package ${validator.packageName};
+
+import javax.faces.el.ValueBinding;
+import javax.faces.context.FacesContext;
+$utils.importTagClasses($validator)
+
+// generated from class $validator.classSource
+// WARNING: This file was automatically generated. Do not edit it directly,
+//          or you will lose your changes.
+public class ${utils.getClassFromFullClass($validator.className)} extends $validator.superClassName
+#if ($validator.implements)
+    implements $validator.implements
+#end
+{
+
+#if ($validator.validatorId)
+    static public final String VALIDATOR_ID = 
+        "$validator.validatorId";
+#end
+
+    public ${utils.getClassFromFullClass($validator.className)}()
+    {
+    }
+    
+#set ($propertyList = ${validator.propertyValidatorList})
+
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#set ($type = $utils.getClassFromFullClass($property.className))
+#if($utils.getDefaultValueField($property)) 
+#set ($defaultValue = $utils.getDefaultValueField($property))
+#else
+#set ($defaultValue = false)
+#end
+    // Property: $property.name
+#if ($property.isLiteralOnly() || $property.isTagExcluded() )
+    private $type $field #if($defaultValue) = $defaultValue;#{else};#{end}
+
+     
+#else
+    private $type $field;
+    
+#end
+#if($utils.isPrimitiveClass($type) && !$property.isTagExcluded() )
+    private boolean ${field}Set;
+    
+#if ($property.isSetMethod())
+    $property.setMethodScope boolean $utils.getPrefixedPropertyName("isSet", $property.name)()
+    {
+        return ${field}Set;
+    }
+#end
+#end
+#if($property.isLocalMethod())
+#if("boolean" == $type)
+#set ($methodName = $utils.getPrefixedPropertyName("isLocal", $property.name))
+#else
+#set ($methodName = $utils.getPrefixedPropertyName("getLocal", $property.name))
+#end
+    final $property.localMethodScope $type ${methodName}()
+    {
+        return $field;
+    }
+     
+#end
+    public $type $utils.getMethodReaderFromProperty($property.name, $type)()
+    {
+#if ($property.isTagExcluded() || $property.isLiteralOnly())
+        return $field;
+#else
+#if ($utils.isPrimitiveClass($type))
+        if (${field}Set)
+#else
+        if ($field != null)
+#end
+        {
+            return $field;
+        }
+        ValueBinding vb = getValueBinding("$property.name");
+        if (vb != null)
+        {
+#if ($utils.isPrimitiveClass($type))
+            return ($utils.castIfNecessary($type) vb.getValue(getFacesContext())).${type}Value();
+#else
+#set ($pritype = $utils.getPrimitiveType($property.className))
+#if ($utils.isPrimitiveClass($pritype))
+            Object value = vb == null ? null : vb.getValue(getFacesContext());
+            if (!(value instanceof $type)){
+                value = ${type}.valueOf(value.toString());
+            }            
+            return $utils.castIfNecessary($type) value;
+#else
+            return $utils.castIfNecessary($type) vb.getValue(getFacesContext());
+#end
+#end
+        }
+#if ($defaultValue)
+        return $defaultValue; 
+#elseif ($utils.isPrimitiveClass($type))
+        return $utils.primitiveDefaultValue($type);
+#else       
+        return null;
+#end
+#end
+    }
+
+    public void $utils.getPrefixedPropertyName("set", $property.name)($type $utils.getVariableFromName($property.name))
+    {
+        this.$field = $utils.getVariableFromName($property.name);
+#if ($utils.isPrimitiveClass($type) && !$property.isTagExcluded() )
+        this.${field}Set = true;        
+#end
+    }
+#end
+
+    public Object saveState(FacesContext facesContext)
+    {
+#set ($primitiveCount = $propertyList.size() + 1)
+#foreach( $property in $propertyList )
+#if($utils.isPrimitiveClass($property.className))
+#set ($primitiveCount = $primitiveCount + 1)
+#end
+#end
+        Object[] values = new Object[$primitiveCount];
+        values[0] = super.saveState(facesContext);
+#set ($arrayIndex = 0)
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#set ($type = $property.className)
+#set ($arrayIndex = $arrayIndex + 1)
+#if ($property.jspName == "validator" && $property.isMethodBinding() )
+        values[$arrayIndex] = saveAttachedState(facesContext,${field}List);
+#elseif ( $property.isStateHolder() )## || $utils.isConverter($type)
+        values[$arrayIndex] = saveAttachedState(facesContext,$field);
+#elseif($utils.isPrimitiveClass($type))
+#if ($type == "boolean")
+        values[$arrayIndex] = ${utils.getBoxedClass($type)}.valueOf($field);
+#else
+        values[$arrayIndex] = new ${utils.getBoxedClass($type)}($field);
+#end
+#else
+        values[$arrayIndex] = $field;
+#end
+#if($utils.isPrimitiveClass($type) && !$property.isTagExcluded())
+#set ($arrayIndex = $arrayIndex + 1)
+        values[$arrayIndex] = Boolean.valueOf(${field}Set);
+#end
+#end
+        return values; 
+    }
+
+    public void restoreState(FacesContext facesContext, Object state)
+    {
+        Object[] values = (Object[])state;
+        super.restoreState(facesContext,values[0]);
+#set ($arrayIndex = 0)
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#set ($type = $property.className)
+#set ($arrayIndex = $arrayIndex + 1)
+#if ( $property.isStateHolder() )
+#if ($property.jspName == "validator" && $property.isMethodBinding() )
+        ${field}List = (List<Validator>) restoreAttachedState(facesContext,values[$arrayIndex]);
+#elseif ($utils.isList($type))
+        $field = (List) restoreAttachedState(facesContext,values[$arrayIndex]);
+#else
+        $field = $utils.castIfNecessary($type) restoreAttachedState(facesContext,values[$arrayIndex]); 
+#end
+#elseif ($utils.isConverter($type)) 
+        $field = (Converter) restoreAttachedState(facesContext,values[$arrayIndex]);
+#elseif ($utils.isPrimitiveClass($type))
+        $field = ($utils.castIfNecessary($type) values[$arrayIndex]).${type}Value();
+#else
+        $field = $utils.castIfNecessary($type) values[$arrayIndex];
+#end
+#if($utils.isPrimitiveClass($type) && !$property.isTagExcluded() )
+#set ($arrayIndex = $arrayIndex + 1)
+        ${field}Set = ((Boolean) values[$arrayIndex]).booleanValue();
+#end
+#end
+    }
+}

Modified: myfaces/tomahawk/trunk/core12/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core12/pom.xml?rev=668332&r1=668331&r2=668332&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core12/pom.xml (original)
+++ myfaces/tomahawk/trunk/core12/pom.xml Mon Jun 16 15:14:26 2008
@@ -378,6 +378,16 @@
             </configuration>
           </execution>          
           <execution>
+            <id>makeval</id>
+            <goals>
+              <goal>make-validators</goal>
+            </goals>
+            <configuration>
+               <jsfVersion>12</jsfVersion>
+               <mainSourceDirectory2>${project.build.directory}/tomahawk11_sources</mainSourceDirectory2>
+            </configuration>
+          </execution>
+          <execution>
             <id>make_tags_myfaces_core</id>
             <configuration>
                 <packageContains>org.apache.myfaces.shared_tomahawk.taglib</packageContains>

Modified: myfaces/tomahawk/trunk/core12/src/main/resources/META-INF/tagValidatorClass12.vm
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core12/src/main/resources/META-INF/tagValidatorClass12.vm?rev=668332&r1=668331&r2=668332&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core12/src/main/resources/META-INF/tagValidatorClass12.vm (original)
+++ myfaces/tomahawk/trunk/core12/src/main/resources/META-INF/tagValidatorClass12.vm Mon Jun 16 15:14:26 2008
@@ -74,6 +74,15 @@
 #set ($className = $utils.getPrimitiveType($property.className))
         if ($field != null)
         {
+#if ($property.isLiteralOnly())
+#if ($utils.isPrimitiveClass($property.className))
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf($field).${property.className}Value());
+#elseif ($utils.isPrimitiveClass($className))
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf($field));
+#else
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}($field);
+#end
+#else        
             if (!${field}.isLiteralText())
             {
                 validator.setValueExpression("$property.name", $field);
@@ -117,6 +126,7 @@
                 validator.${utils.getPrefixedPropertyName("set",$property.name)}(($property.className)  ${field}.getValue(facesContext.getELContext()));
 #end
             }
+#end
         }
 #end
     }

Added: myfaces/tomahawk/trunk/core12/src/main/resources/META-INF/validatorClass12.vm
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core12/src/main/resources/META-INF/validatorClass12.vm?rev=668332&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core12/src/main/resources/META-INF/validatorClass12.vm (added)
+++ myfaces/tomahawk/trunk/core12/src/main/resources/META-INF/validatorClass12.vm Mon Jun 16 15:14:26 2008
@@ -0,0 +1,212 @@
+## Velocity template used to generate JSF1.1-compatible validator classes
+## from validator meta-data.
+##
+## Note that there are only one type of validator generation:
+##  * "subclass mode" (use annotated class as a parent class)
+##
+## Variable $validator refers to a ComponentMeta object to process
+## Variable $utils refers to an instance of MyfacesUtils.
+##
+## When "template mode" is being used then variable $innersource
+## holds a String containing all the non-abstract functions defined
+## in the annotated class.
+##
+## The java package of the generated class is always the same as
+## the package in which the annotated class exists.
+##
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package ${validator.packageName};
+
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+$utils.importTagClasses($validator)
+
+// generated from class $validator.classSource
+// WARNING: This file was automatically generated. Do not edit it directly,
+//          or you will lose your changes.
+public class ${utils.getClassFromFullClass($validator.className)} extends $validator.superClassName
+#if ($validator.implements)
+    implements $validator.implements
+#end
+{
+
+#if ($validator.validatorId)
+    static public final String VALIDATOR_ID = 
+        "$validator.validatorId";
+#end
+
+    public ${utils.getClassFromFullClass($validator.className)}()
+    {
+    }
+    
+#set ($propertyList = ${validator.propertyValidatorList})
+
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#set ($type = $utils.getClassFromFullClass($property.className))
+#if($utils.getDefaultValueField($property)) 
+#set ($defaultValue = $utils.getDefaultValueField($property))
+#else
+#set ($defaultValue = false)
+#end
+    // Property: $property.name
+#if ($property.isLiteralOnly() || $property.isTagExcluded() )
+    private $type $field #if($defaultValue) = $defaultValue;#{else};#{end}
+
+     
+#else
+    private $type $field;
+    
+#end
+#if($utils.isPrimitiveClass($type) && !$property.isTagExcluded() )
+    private boolean ${field}Set;
+    
+#if ($property.isSetMethod())
+    $property.setMethodScope boolean $utils.getPrefixedPropertyName("isSet", $property.name)()
+    {
+        return ${field}Set;
+    }
+#end
+#end
+#if($property.isLocalMethod())
+#if("boolean" == $type)
+#set ($methodName = $utils.getPrefixedPropertyName("isLocal", $property.name))
+#else
+#set ($methodName = $utils.getPrefixedPropertyName("getLocal", $property.name))
+#end
+    final $property.localMethodScope $type ${methodName}()
+    {
+        return $field;
+    }
+     
+#end
+    public $type $utils.getMethodReaderFromProperty($property.name, $type)()
+    {
+#if ($property.isTagExcluded() || $property.isLiteralOnly())
+        return $field;
+#else
+#if ($utils.isPrimitiveClass($type))
+        if (${field}Set)
+#else
+        if ($field != null)
+#end
+        {
+            return $field;
+        }
+        ValueExpression vb = getValueExpression("$property.name");
+        if (vb != null)
+        {
+#if ($utils.isPrimitiveClass($type))
+            return ($utils.castIfNecessary($type) vb.getValue(getFacesContext().getELContext())).${type}Value();
+#else
+#set ($pritype = $utils.getPrimitiveType($property.className))
+#if ($utils.isPrimitiveClass($pritype))
+            Object value = vb == null ? null : vb.getValue(getFacesContext().getELContext());
+            if (!(value instanceof $type)){
+                value = ${type}.valueOf(value.toString());
+            }            
+            return $utils.castIfNecessary($type) value;
+#else
+            return $utils.castIfNecessary($type) vb.getValue(getFacesContext().getELContext());
+#end
+#end
+        }
+#if ($defaultValue)
+        return $defaultValue; 
+#elseif ($utils.isPrimitiveClass($type))
+        return $utils.primitiveDefaultValue($type);
+#else       
+        return null;
+#end
+#end
+    }
+
+    public void $utils.getPrefixedPropertyName("set", $property.name)($type $utils.getVariableFromName($property.name))
+    {
+        this.$field = $utils.getVariableFromName($property.name);
+#if ($utils.isPrimitiveClass($type) && !$property.isTagExcluded() )
+        this.${field}Set = true;        
+#end
+    }
+#end
+
+    public Object saveState(FacesContext facesContext)
+    {
+#set ($primitiveCount = $propertyList.size() + 1)
+#foreach( $property in $propertyList )
+#if($utils.isPrimitiveClass($property.className))
+#set ($primitiveCount = $primitiveCount + 1)
+#end
+#end
+        Object[] values = new Object[$primitiveCount];
+        values[0] = super.saveState(facesContext);
+#set ($arrayIndex = 0)
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#set ($type = $property.className)
+#set ($arrayIndex = $arrayIndex + 1)
+#if ($property.jspName == "validator" && $property.isMethodBinding() )
+        values[$arrayIndex] = saveAttachedState(facesContext,${field}List);
+#elseif ( $property.isStateHolder() )## || $utils.isConverter($type)
+        values[$arrayIndex] = saveAttachedState(facesContext,$field);
+#elseif($utils.isPrimitiveClass($type))
+        values[$arrayIndex] = ${utils.getBoxedClass($type)}.valueOf($field);
+#else
+        values[$arrayIndex] = $field;
+#end
+#if($utils.isPrimitiveClass($type) && !$property.isTagExcluded())
+#set ($arrayIndex = $arrayIndex + 1)
+        values[$arrayIndex] = Boolean.valueOf(${field}Set);
+#end
+#end
+        return values; 
+    }
+
+    public void restoreState(FacesContext facesContext, Object state)
+    {
+        Object[] values = (Object[])state;
+        super.restoreState(facesContext,values[0]);
+#set ($arrayIndex = 0)
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#set ($type = $property.className)
+#set ($arrayIndex = $arrayIndex + 1)
+#if ( $property.isStateHolder() )
+#if ($property.jspName == "validator" && $property.isMethodBinding() )
+        ${field}List = (List<Validator>) restoreAttachedState(facesContext,values[$arrayIndex]);
+#elseif ($utils.isList($type))
+        $field = (List) restoreAttachedState(facesContext,values[$arrayIndex]);
+#else
+        $field = $utils.castIfNecessary($type) restoreAttachedState(facesContext,values[$arrayIndex]); 
+#end
+#elseif ($utils.isConverter($type)) 
+        $field = (Converter) restoreAttachedState(facesContext,values[$arrayIndex]);
+#elseif ($utils.isPrimitiveClass($type))
+        $field = ($utils.castIfNecessary($type) values[$arrayIndex]).${type}Value();
+#else
+        $field = $utils.castIfNecessary($type) values[$arrayIndex];
+#end
+#if($utils.isPrimitiveClass($type) && !$property.isTagExcluded() )
+#set ($arrayIndex = $arrayIndex + 1)
+        ${field}Set = ((Boolean) values[$arrayIndex]).booleanValue();
+#end
+#end
+    }
+}

Modified: myfaces/tomahawk/trunk/sandbox/core/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/pom.xml?rev=668332&r1=668331&r2=668332&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/pom.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/pom.xml Mon Jun 16 15:14:26 2008
@@ -227,7 +227,13 @@
 			      <goals>
 			        <goal>make-components</goal>
 			      </goals>
-			    </execution>          
+			    </execution>
+				<execution>
+				  <id>makeval</id>
+				  <goals>
+				    <goal>make-validators</goal>
+				  </goals>
+				</execution>
 			    <execution>
 			      <id>maketags</id>
 			      <goals>

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/AbstractCompareToValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/AbstractCompareToValidator.java?rev=668332&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/AbstractCompareToValidator.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/AbstractCompareToValidator.java Mon Jun 16 15:14:26 2008
@@ -0,0 +1,497 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.comparetovalidator;
+
+import java.util.Comparator;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.el.ValueBinding;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.Renderer;
+import javax.faces.validator.ValidatorException;
+
+import org.apache.myfaces.shared_tomahawk.util.MessageUtils;
+import org.apache.myfaces.shared_tomahawk.util._ComponentUtils;
+import org.apache.myfaces.validator.ValidatorBase;
+
+/**
+ * 
+ * Validates this component against another component.
+ * 
+ * Specify the foreign component with the for={foreign-component-id} attribute.
+ *
+ * Valid operator attribute values:
+ * 
+ *   equals:                  eq, ==, =,
+ * 	 not equals:              ne, !=,
+ *   greater than:            gt, >,
+ *   less than:               lt, <,
+ *   greater than or equals:  ge, >=,
+ *   less than or equals:     le, <=
+ *
+ * If the comparator attribute is specified, the component values are compared
+ * using the specified java.util.Comparator object.
+ * If no comparator is specified, the component values must implement Comparable
+ * and are compared using compareTo().
+ * If either value or foreign value does not implement Comparable and no Comparator
+ * is specified, validation always succeeds.
+ *
+ * Put this validator on the bottom-most component to insure that
+ * the foreign component's value has been converted and validated first.
+ * 
+ * However, this validator will attempt to convert and validate the foreign
+ * component's value if this has not already occurred.  This process may not
+ * be identical to the standard JSF conversion and validation process.
+ * 
+ * The validation error message key is currently hardcoded as
+ * 
+ *     "{0} value <{1}> must be {2} {3} value <{4}>"
+ * 
+ * where {0} is the parent component id,
+ *       {1} is the parent component value,
+ *       {2} is the operator name,
+ *       {3} is the foreign component id, and
+ *       {4} is the foreign component value.
+ * 
+ * The alternateOperatorName attribute can specify a custom operator name.
+ * For example, use "after" instead of "greater than" when comparing dates.
+ * 
+ * The message attribute can specify an alternate validation error message key.
+ * For example, use "{0} must be {2} {3}" to remove values from the message.
+ *
+ * 
+ * faces-config.xml configuration:
+ * 
+ * 	<validator>
+ * 		<description>CompareTo validator</description>
+ * 		<validator-id>org.apache.myfaces.validator.CompareTo</validator-id>
+ * 		<validator-class>org.apache.myfaces.custom.comparetovalidator.CompareToValidator</validator-class>
+ * 	</validator>
+ * 
+ * 
+ * Facelets configuration (inside a taglib.xml file):
+ * 
+ * <tag>
+ *      <tag-name>compareToValidator</tag-name>
+ *      <validator>
+ *          <validator-id>org.apache.myfaces.validator.CompareTo</validator-id>
+ *      </validator>
+ *  </tag>
+ * 
+ * 
+ * Example usage:
+ * 
+ *   <t:inputCalendar id="startDate"/>
+ *   <t:inputCalendar id="endDate">
+ *       <sandbox:compareToValidator operator="gt" for="startDate" />
+ *       <sandbox:compareToValidator operator="gt" for="startDate" message="Start date must be before end date." />
+ *       <sandbox:compareToValidator operator="gt" for="startDate" message="{0} must be {2} {3}" />
+ *       <sandbox:compareToValidator operator="gt" for="startDate" alternateOperatorName="after" />
+ *       <sandbox:compareToValidator operator="gt" for="startDate" message="{0} must be {2} {3}" alternateOperatorName="after" />
+ *       <sandbox:compareToValidator operator="gt" for="startDate" comparator="#{dateComparator}" />
+ *   <t:inputCalendar>
+ * 
+ * 
+ * Known issues:
+ *   - Operator names should be localized.
+ *   - The default message key should be localized.
+ *   - Perhaps an exception should be thrown if the two values are not Comparable and no Comparator is specified.
+ *   
+ * @JSFValidator
+ *   name = "s:validateCompareTo"
+ *   class = "org.apache.myfaces.custom.comparetovalidator.CompareToValidator"
+ *   tagClass = "org.apache.myfaces.custom.comparetovalidator.ValidateCompareToTag"
+ *   serialuidtag = "-8879289182242196266L"
+ *   
+ * @author Mike Kienenberger (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public abstract class AbstractCompareToValidator extends ValidatorBase {
+    /**
+     * <p>The standard converter id for this converter.</p>
+     */
+    public static final String 	VALIDATOR_ID 	   = "org.apache.myfaces.validator.CompareTo";
+
+    /**
+     * <p>The message identifier of the {@link FacesMessage} to be created if
+     * the comparison check fails.</p>
+     */
+    // public static final String COMPARE_TO_MESSAGE_ID = "org.apache.myfaces.CompareTo.INVALID";
+    public static final String COMPARE_TO_MESSAGE_ID = "{0} value <{1}> must be {2} {3} value <{4}>";
+
+    public AbstractCompareToValidator(){
+        super();
+    }
+
+    public static final String OPERATOR_EQUALS = "eq";
+    public static final String OPERATOR_NOT_EQUALS = "ne";
+    public static final String OPERATOR_GREATER_THAN = "gt";
+    public static final String OPERATOR_LESS_THAN = "lt";
+    public static final String OPERATOR_GREATER_THAN_OR_EQUALS = "ge";
+    public static final String OPERATOR_LESS_THAN_OR_EQUALS = "le";
+
+    public static final String OPERATOR_EQUALS_ALT = "==";
+    public static final String OPERATOR_NOT_EQUALS_ALT = "!=";
+    public static final String OPERATOR_GREATER_THAN_ALT = ">";
+    public static final String OPERATOR_LESS_THAN_ALT = "<";
+    public static final String OPERATOR_GREATER_THAN_OR_EQUALS_ALT = ">=";
+    public static final String OPERATOR_LESS_THAN_OR_EQUALS_ALT = "<=";
+
+    public static final String OPERATOR_EQUALS_ALT2 = "=";
+
+    protected String getOperatorForString(String operatorSpecified)
+    {
+        if (OPERATOR_EQUALS.equalsIgnoreCase(operatorSpecified))
+            return OPERATOR_EQUALS;
+        else if (OPERATOR_NOT_EQUALS.equalsIgnoreCase(operatorSpecified))
+            return OPERATOR_NOT_EQUALS;
+        else if (OPERATOR_GREATER_THAN.equalsIgnoreCase(operatorSpecified))
+            return OPERATOR_GREATER_THAN;
+        else if (OPERATOR_LESS_THAN.equalsIgnoreCase(operatorSpecified))
+            return OPERATOR_LESS_THAN;
+        else if (OPERATOR_GREATER_THAN_OR_EQUALS.equalsIgnoreCase(operatorSpecified))
+            return OPERATOR_GREATER_THAN_OR_EQUALS;
+        else if (OPERATOR_LESS_THAN_OR_EQUALS.equalsIgnoreCase(operatorSpecified))
+            return OPERATOR_LESS_THAN_OR_EQUALS;
+
+        else if (OPERATOR_EQUALS_ALT.equalsIgnoreCase(operatorSpecified))
+            return OPERATOR_EQUALS;
+        else if (OPERATOR_NOT_EQUALS_ALT.equalsIgnoreCase(operatorSpecified))
+            return OPERATOR_NOT_EQUALS;
+        else if (OPERATOR_GREATER_THAN_ALT.equalsIgnoreCase(operatorSpecified))
+            return OPERATOR_GREATER_THAN;
+        else if (OPERATOR_LESS_THAN_ALT.equalsIgnoreCase(operatorSpecified))
+            return OPERATOR_LESS_THAN;
+        else if (OPERATOR_GREATER_THAN_OR_EQUALS_ALT.equalsIgnoreCase(operatorSpecified))
+            return OPERATOR_GREATER_THAN_OR_EQUALS;
+        else if (OPERATOR_LESS_THAN_OR_EQUALS_ALT.equalsIgnoreCase(operatorSpecified))
+            return OPERATOR_LESS_THAN_OR_EQUALS;
+
+        else if (OPERATOR_EQUALS_ALT2.equalsIgnoreCase(operatorSpecified))
+            return OPERATOR_EQUALS;
+
+        throw new IllegalStateException("Operator has unknown value of '" + operatorSpecified + "'");
+    }
+
+    protected String nameForOperator(String operator)
+    {
+        if (OPERATOR_EQUALS == operator)
+            return "equal to";
+        else if (OPERATOR_NOT_EQUALS == operator)
+            return "inequal to";
+        else if (OPERATOR_GREATER_THAN == operator)
+            return "greater than";
+        else if (OPERATOR_LESS_THAN == operator)
+            return "less than";
+        else if (OPERATOR_GREATER_THAN_OR_EQUALS == operator)
+            return "greater than or equal to";
+        else if (OPERATOR_LESS_THAN_OR_EQUALS == operator)
+            return "less than or equal to";
+
+        throw new IllegalStateException("Operator has unknown value of '" + operator + "'");
+    }
+
+    protected boolean validateOperatorOnComparisonResult(String operator, int result)
+    {
+        if (OPERATOR_EQUALS == operator)
+            return result == 0;
+        else if (OPERATOR_NOT_EQUALS == operator)
+            return result != 0;
+        else if (OPERATOR_GREATER_THAN == operator)
+            return result > 0;
+        else if (OPERATOR_LESS_THAN == operator)
+            return result < 0;
+        else if (OPERATOR_GREATER_THAN_OR_EQUALS == operator)
+            return result >= 0;
+        else if (OPERATOR_LESS_THAN_OR_EQUALS == operator)
+            return result <= 0;
+
+        throw new IllegalStateException("Operator has unknown value of '" + operator + "'");
+    }
+
+    public void validate(
+        FacesContext facesContext,
+        UIComponent uiComponent,
+        Object value)
+        throws ValidatorException {
+
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+        // Don't perform validation if the value is null
+        if (value == null)
+        {
+            return;
+        }
+
+		String foreignComponentName = getFor();
+
+		UIComponent foreignComponent = (UIComponent) uiComponent.getParent().findComponent(foreignComponentName);
+        if(foreignComponent == null)
+            throw new FacesException("Unable to find component '" + foreignComponentName + "' (calling findComponent on component '" + uiComponent.getId() + "')");
+
+        if(false == foreignComponent instanceof EditableValueHolder)
+            throw new FacesException("Component '" + foreignComponent.getId() + "' does not implement EditableValueHolder");
+        EditableValueHolder foreignEditableValueHolder = (EditableValueHolder)foreignComponent;
+
+        if (foreignEditableValueHolder.isRequired() && foreignEditableValueHolder.getValue()== null ) {
+            return;
+        }
+
+        Object foreignValue;
+        if (foreignEditableValueHolder.isValid())
+        {
+            foreignValue = foreignEditableValueHolder.getValue();
+        }
+        else
+        {
+            try 
+            {
+                foreignValue = getConvertedValueNonValid(facesContext, foreignComponent);
+            }
+            catch(ConverterException e)
+            {
+                /*
+                 * If the value cannot be converted this should return,
+                 * because does not have sense compare one
+                 * foreign invalid value with other value.
+                 * this force end the validation but do not continue
+                 * with the next phases, because the converter
+                 * of the foreign component fails and show a validation error.
+                 */
+                return;
+            }
+        }
+
+        // Don't perform validation if the foreign value is null
+        if (null == foreignValue)
+        {
+            return;
+        }
+
+        String operator = getOperatorForString(getOperator());
+
+        String alternateOperatorName = getAlternateOperatorName();
+        Object[] args = {
+                uiComponent.getId(),
+                value.toString(),
+                (alternateOperatorName == null) ? nameForOperator(operator) : alternateOperatorName,
+                foreignComponent.getId(),
+                (foreignValue == null) ? foreignComponent.getId() : foreignValue.toString()
+        };
+
+        String message = getMessage();
+        if (null == message)  message = COMPARE_TO_MESSAGE_ID;
+
+        Comparator comparator = createComparator();
+
+        if (null != comparator)
+        {
+            if (false == validateOperatorOnComparisonResult(operator, comparator.compare(value, foreignValue)))
+            {
+                throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, message, args));
+            }
+        }
+        else if ( (value instanceof Comparable) && (foreignValue instanceof Comparable) )
+        {
+            try
+            {
+                if (false == validateOperatorOnComparisonResult(operator, ((Comparable)value).compareTo(foreignValue)))
+                {
+                    throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, message, args));
+                }
+            }
+            catch (RuntimeException exception)
+            {
+                if (exception instanceof ValidatorException)
+                {
+                    throw exception;
+                }
+                else
+                {
+                    throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, message + ": " + exception.getLocalizedMessage(), args));
+                }
+            }
+        }
+        else if (value instanceof Comparable)
+        {
+            throw new ClassCastException(getClassCastExceptionMessage(foreignComponent.getId(), Comparable.class, foreignValue));
+        }
+        else if (foreignValue instanceof Comparable)
+        {
+            throw new ClassCastException(getClassCastExceptionMessage(uiComponent.getId(), Comparable.class, value));
+        }
+    }
+
+    protected String getClassCastExceptionMessage(String name, Class clazz, Object object)
+    {
+        if (null == object)
+            return name + " must be type " + clazz + " but is null";
+        else return name + " must be type " + clazz + " but is type " + object.getClass();
+    }
+
+    protected Comparator createComparator()
+    {
+        Object comparator = getComparator();
+
+        if (null == comparator)  return null;
+
+        if (false == comparator instanceof Comparator)
+        {
+            throw new ClassCastException(getClassCastExceptionMessage("comparator", Comparator.class, comparator));
+        }
+
+        return (Comparator)comparator;
+    }
+
+    // -------------------------------------------------------- GETTER & SETTER
+
+    /**
+     * The JSF id of the component with which to compare values.
+     * 
+     * @JSFProperty
+     * @return the foreign component_id, on which a value should be validated
+     */
+    public abstract String getFor();
+
+    /**
+     * @param string the foreign component_id, on which a value should be validated
+     */
+    public abstract void setFor(String string);
+
+    /**
+     * Operator for comparison: equals: eq, ==, =, not equals: ne, !=, greater than: gt, >, less than: lt, <, greater than or equals: ge, >=, less than or equals: le, <=
+     * 
+     * @JSFProperty
+     * @return
+     */
+    public abstract String getOperator();
+
+    public abstract void setOperator(String operator);
+
+    /**
+     * Value binding for an alternate java.util.Comparator object if component 
+     * values don't implement Comparable
+     * 
+     * @JSFProperty
+     * @return
+     */
+    public abstract Object getComparator();
+
+    public abstract void setComparator(Object comparator);
+
+    /**
+     * custom operator name in error message (ie "after" instead of "greater than" for dates)
+     * 
+     * @JSFProperty
+     * @return
+     */
+    public abstract String getAlternateOperatorName();
+
+    public abstract void setAlternateOperatorName(String alternateOperatorName);
+
+    // ---------------- Borrowed to convert foreign submitted values
+
+    protected Renderer getRenderer(FacesContext context, UIComponent foreignComponent)
+    {
+        if (context == null) throw new NullPointerException("context");
+        String rendererType = foreignComponent.getRendererType();
+        if (rendererType == null) return null;
+        String renderKitId = context.getViewRoot().getRenderKitId();
+        RenderKitFactory rkf = (RenderKitFactory)FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+        RenderKit renderKit = rkf.getRenderKit(context, renderKitId);
+        Renderer renderer = renderKit.getRenderer(foreignComponent.getFamily(), rendererType);
+        if (renderer == null)
+        {
+            getFacesContext().getExternalContext().log("No Renderer found for component " + foreignComponent + " (component-family=" + foreignComponent.getFamily() + ", renderer-type=" + rendererType + ")");
+        }
+        return renderer;
+    }
+
+    protected Converter findUIOutputConverter(FacesContext facesContext, UIComponent component)
+    {
+        Converter converter = ((EditableValueHolder)component).getConverter();
+        if (converter != null) return converter;
+
+        //Try to find out by value binding
+        ValueBinding vb = component.getValueBinding("value");
+        if (vb == null) return null;
+
+        Class valueType = vb.getType(facesContext);
+        if (valueType == null) return null;
+
+        if (String.class.equals(valueType)) return null;    //No converter needed for String type
+        if (Object.class.equals(valueType)) return null;    //There is no converter for Object class
+
+        try
+        {
+            return facesContext.getApplication().createConverter(valueType);
+        }
+        catch (FacesException e)
+        {
+            getFacesContext().getExternalContext().log("No Converter for type " + valueType.getName() + " found", e);
+            return null;
+        }
+    }
+
+
+    // --------------------- borrowed and modified from UIInput ------------
+
+    protected Object getConvertedValueNonValid(FacesContext facesContext, UIComponent component)
+        throws ConverterException
+    {
+        Object componentValueObject;
+        Object submittedValue = ((EditableValueHolder) component).getSubmittedValue();
+        if (submittedValue == null)
+        {
+            componentValueObject = null;
+        }
+        else
+        {
+            Renderer renderer = getRenderer(facesContext, component);
+            if (renderer != null)
+            {
+                componentValueObject = renderer.getConvertedValue(facesContext, component, submittedValue);
+            }
+            else if (submittedValue instanceof String)
+            {
+                Converter converter = findUIOutputConverter(facesContext, component);
+                if (converter != null)
+                {
+                    componentValueObject = converter.getAsObject(facesContext, component, (String)submittedValue);
+                }
+                else
+                {
+                    componentValueObject = submittedValue;
+                }
+            }else{
+                componentValueObject = submittedValue;
+            }
+        }
+        return componentValueObject;
+    }
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/AbstractCompareToValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/AbstractCompareToValidator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/AbstractCSVValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/AbstractCSVValidator.java?rev=668332&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/AbstractCSVValidator.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/AbstractCSVValidator.java Mon Jun 16 15:14:26 2008
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.csvvalidator;
+import java.util.regex.PatternSyntaxException;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+import org.apache.myfaces.shared_tomahawk.util.MessageUtils;
+import org.apache.myfaces.validator.ValidatorBase;
+
+/**
+ * Validation by validating comma separated values individually.
+ * 
+ * @JSFValidator
+ *   name = "s:validateCSV"
+ *   class = "org.apache.myfaces.custom.csvvalidator.CSVValidator"
+ *   tagClass = "org.apache.myfaces.custom.csvvalidator.ValidateCSVTag"
+ *   serialuidtag = "-8874279182242196266L"
+ *
+ * @author Lance Frohman
+ *
+ * @version $Revision$ $Date$
+ */
+public abstract class AbstractCSVValidator extends ValidatorBase {
+	/**
+	 * <p>The standard converter id for this converter.</p>
+	 */
+	public static final String VALIDATOR_ID = "org.apache.myfaces.validator.csv";
+	/**
+	 * <p>The message identifiers of the {@link FacesMessage} to be created if
+	 * the check fails.</p>
+	 */
+	public static final String CSV_NOT_STRING_MESSAGE_ID = "org.apache.myfaces.csv.NOT_STRING";
+	public static final String CSV_INVALID_SEPARATOR_MESSAGE_ID = "org.apache.myfaces.csv.INVALID_SEPARATOR";
+	public static final String CSV_SUFFIX_MESSAGE_ID = "org.apache.myfaces.csv.SUFFIX";
+	private static final String DEFAULT_SEPARATOR = ",";
+
+	/**
+	 * @JSFProperty
+	 * @return the VALIDATOR_ID of the actual validator to be used
+	 */
+    public abstract String getSubvalidatorId();
+
+	/**
+	 * @param the VALIDATOR_ID of the actual validator to be used
+	 */
+	public abstract void setSubvalidatorId(String subvalidatorId);
+
+	/**
+	 * @JSFProperty
+	 * @return the separator character to separate values
+	 */
+	public abstract String getSeparator();
+
+	/**
+	 * @param the separator character to separate values
+	 */
+	public abstract void setSeparator(String separator);
+
+	private FacesMessage addMessage(FacesMessage oldMsg, FacesMessage newMsg, int index, String suffixMessageKey) {
+		if (oldMsg != null && newMsg.getSeverity().getOrdinal() < oldMsg.getSeverity().getOrdinal())
+			return oldMsg;
+		String summaryMessageText = null;
+		String detailMessageText = null;
+		if (oldMsg == null || newMsg.getSeverity().getOrdinal() > oldMsg.getSeverity().getOrdinal()) {
+			summaryMessageText = null;
+			detailMessageText = null;
+		}
+		else {
+			summaryMessageText = oldMsg.getSummary();
+			detailMessageText = oldMsg.getDetail();
+		}
+		Object[] args = { new Integer(index + 1) };
+		FacesMessage suffixMessage = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, suffixMessageKey, args);
+		String summarySuffix = suffixMessage.getSummary();
+		String detailSuffix = suffixMessage.getDetail();
+		if (summarySuffix == null)
+			summarySuffix = detailSuffix;
+		else if (detailSuffix == null)
+			detailSuffix = summarySuffix;
+		String summary = newMsg.getSummary();
+		if (summaryMessageText == null)
+			summaryMessageText = summary + summarySuffix;
+		else
+			summaryMessageText += ", " + summary + summarySuffix;
+		String detail = newMsg.getDetail();
+		if (detailMessageText == null)
+			detailMessageText = detail + detailSuffix;
+		else
+			detailMessageText += ", " + detail + detailSuffix;
+		return new FacesMessage(newMsg.getSeverity(), summaryMessageText, detailMessageText);
+	}
+
+	public void validate(FacesContext facesContext, UIComponent uiComponent, Object value) throws ValidatorException {
+
+		if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+		if (value == null)
+		{
+		    return;
+		}
+
+		String suffixMessageKey = getMessage();
+	    if (suffixMessageKey == null)
+	    	suffixMessageKey = CSV_SUFFIX_MESSAGE_ID;
+		FacesMessage facesMsg = null;
+		// value must be a String
+		if (!(value instanceof String)) {
+			Object[] args = { value };
+            throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, CSV_NOT_STRING_MESSAGE_ID, args));
+		}
+	    Validator validator = facesContext.getApplication().createValidator(getSubvalidatorId());
+	    if (getSeparator() == null)
+	    	setSeparator(DEFAULT_SEPARATOR);
+	    String[] values = null;
+	    try {
+			values = ((String)value).split(getSeparator());
+	    }
+	    catch (PatternSyntaxException e) {
+			Object[] args = { getSeparator() };
+            throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, CSV_INVALID_SEPARATOR_MESSAGE_ID, args));
+	    }
+		// loop through the separated values and validate each one
+		for (int i = 0; i < values.length; i++) {
+			if (values[i].trim().length() == 0) {
+				continue;
+			}
+			else try {
+				validator.validate(facesContext, uiComponent, values[i]);
+			}
+			catch (ValidatorException e) {
+				facesMsg = addMessage(facesMsg, e.getFacesMessage(), i, suffixMessageKey);
+			}
+		}
+		if (facesMsg != null)
+			throw new ValidatorException(facesMsg);
+	}
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/AbstractCSVValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/AbstractCSVValidator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/AbstractUrlValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/AbstractUrlValidator.java?rev=668332&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/AbstractUrlValidator.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/AbstractUrlValidator.java Mon Jun 16 15:14:26 2008
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.custom.urlvalidator;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.ValidatorException;
+
+import org.apache.myfaces.validator.ValidatorBase;
+
+/**
+ * A custom validator for url format, based upons Jakarta Commons.
+ * 
+ * @JSFValidator
+ *   name = "s:validateUrl"
+ *   class = "org.apache.myfaces.custom.urlvalidator.UrlValidator"
+ *   tagClass = "org.apache.myfaces.custom.urlvalidator.ValidateUrlTag"
+ *   serialuidtag = "6041422002721046221L"
+ *
+ * @author Fabian Frederick
+ *
+ * @version $Revision$ $Date$
+ */
+public abstract class AbstractUrlValidator extends ValidatorBase {
+
+	/**
+	 * <p>The standard converter id for this converter.</p>
+	 */
+	public static final String 	VALIDATOR_ID 	   = "org.apache.myfaces.validator.Url";
+	/**
+	 * <p>The message identifier of the {@link FacesMessage} to be created if
+	 * the maximum length check fails.</p>
+	 */
+	public static final String URL_MESSAGE_ID = "org.apache.myfaces.Url.INVALID";
+	 
+	public AbstractUrlValidator(){
+
+	}
+
+	/**
+	 * method that validates an url address.
+	 * it uses the commons-validator
+	 */
+	public void validate(
+		FacesContext facesContext,
+		UIComponent uiComponent,
+		Object value)
+		throws ValidatorException {
+
+
+			if (facesContext == null) throw new NullPointerException("facesContext");
+			if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+			if (value == null)
+			{
+				return;
+			}
+			
+			org.apache.commons.validator.UrlValidator urlValidator = initValidator();
+			
+			if (!urlValidator.isValid(value.toString())) {
+				Object[] args = {value.toString()};
+				throw new ValidatorException(getFacesMessage(URL_MESSAGE_ID, args));
+            }
+
+	}
+	
+	private org.apache.commons.validator.UrlValidator initValidator()
+	{
+        int options = 0;
+        
+        if (isAllow2Slashes())
+        {
+            options = options | org.apache.commons.validator.UrlValidator.ALLOW_2_SLASHES; 
+        }
+        
+        if (isAllowAllSchemas())
+        {
+            options = options | org.apache.commons.validator.UrlValidator.ALLOW_ALL_SCHEMES;
+        }
+        
+        String [] schemesList = getSchemesList(); 
+        org.apache.commons.validator.UrlValidator urlValidator = null;
+        if (schemesList == null){
+            urlValidator = new 
+                org.apache.commons.validator.UrlValidator(options);
+        }
+        else
+        {
+            urlValidator = new 
+                org.apache.commons.validator.UrlValidator(schemesList,options);
+        }
+        return urlValidator;
+	}
+	
+	private String[] getSchemesList(){
+	    if (getSchemes() == null)
+	    {
+	        return null;
+	    }
+	    String [] list = getSchemes().split(",");
+	    String [] resp = new String [list.length];
+	    
+	    for (int i = 0; i < list.length; i++)
+	    {
+	        resp[i] = list[i].trim();
+	    }	    
+	    return resp;	    
+	}
+    	
+	public abstract void setSchemes(String _schemes);
+
+	/**
+	 *  CSV values that indicates the set of schemes to check this url.
+	 *  
+	 *  If allowAllSchemas = true, the values of this field are ignored.
+	 * 
+	 *  If no schemes are provided, default to this set ("http", "https", "ftp").
+	 * 
+	 * @JSFProperty
+	 */
+    public abstract String getSchemes();
+
+    public abstract void setAllow2Slashes(boolean _allow2Slashes);
+
+    /**
+     *  Allow two slashes in the path component of the URL.
+     * 
+     * @JSFProperty
+     *   defaultValue = "false"
+     */
+    public abstract boolean isAllow2Slashes();
+
+    public abstract void setAllowAllSchemas(boolean _allowAllSchemas);
+
+    /**
+     *  Allows all validly formatted schemes to pass validation instead of 
+     *  supplying a set of valid schemes.
+     *  
+     * @JSFProperty
+     *   defaultValue = "false"
+     */
+    public abstract boolean isAllowAllSchemas();
+
+}

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/AbstractUrlValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/AbstractUrlValidator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/componentClass11.vm
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/componentClass11.vm?rev=668332&r1=668331&r2=668332&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/componentClass11.vm (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/componentClass11.vm Mon Jun 16 15:14:26 2008
@@ -1,5 +1,21 @@
-// WARNING: This file was automatically generated. Do not edit it directly,
-//          or you will lose your changes.
+## Velocity template used to generate JSF1.1-compatible component classes
+## from component meta-data.
+##
+## Note that there are two types of component generation:
+##  * "subclass mode" (use annotated class as a parent class)
+##  * "template mode" (use annotated class as a template)
+## This template file is used for both.
+##
+## Variable $component refers to a ComponentMeta object to process
+## Variable $utils refers to an instance of MyfacesUtils.
+##
+## When "template mode" is being used then variable $innersource
+## holds a String containing all the non-abstract functions defined
+## in the annotated class.
+##
+## The java package of the generated class is always the same as
+## the package in which the annotated class exists.
+##
 /*
  *  Licensed to the Apache Software Foundation (ASF) under one
  *  or more contributor license agreements.  See the NOTICE file
@@ -25,6 +41,9 @@
 import javax.faces.context.FacesContext;
 $utils.importTagClasses($component)
 
+// generated from class $component.classSource
+// WARNING: This file was automatically generated. Do not edit it directly,
+//          or you will lose your changes.
 public class ${utils.getClassFromFullClass($component.className)} extends $component.superClassName
 #if ($component.implements)
     implements $component.implements

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagValidatorClass11.vm
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagValidatorClass11.vm?rev=668332&r1=668331&r2=668332&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagValidatorClass11.vm (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagValidatorClass11.vm Mon Jun 16 15:14:26 2008
@@ -66,6 +66,15 @@
 #set ($className = $utils.getPrimitiveType($property.className))
         if ($field != null)
         {
+#if ($property.isLiteralOnly())
+#if ($utils.isPrimitiveClass($property.className))
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf($field).${property.className}Value());
+#elseif ($utils.isPrimitiveClass($className))
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf($field));
+#else
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}($field);
+#end
+#else
             if (UIComponentTag.isValueReference($field))
             {
                 ValueBinding vb = facesContext.getApplication().createValueBinding($field);
@@ -89,6 +98,7 @@
                 validator.${utils.getPrefixedPropertyName("set",$property.name)}($field);
 #end
             }
+#end
         }
 #end
         return validator;