You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lf...@apache.org on 2006/08/23 23:34:28 UTC

svn commit: r434193 - in /myfaces/tomahawk/trunk/sandbox: core/src/main/java/org/apache/myfaces/custom/csvvalidator/ core/src/main/resources-facesconfig/META-INF/ core/src/main/tld/ core/src/main/tld/entities/ core/src/site/xdoc/ examples/src/main/java...

Author: lfrohman
Date: Wed Aug 23 14:34:27 2006
New Revision: 434193

URL: http://svn.apache.org/viewvc?rev=434193&view=rev
Log:
New validator - Tomahawk-182 - comma separated validator

Added:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/
    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/csvvalidator/ValidateCSVTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/csvvalidator_attributes.xml
    myfaces/tomahawk/trunk/sandbox/core/src/site/xdoc/CSVvalidator.xml
    myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/validate/
    myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/validate/ValidateForm.java
    myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/validateCSV.jsp
Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
    myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml
    myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/CSVValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/CSVValidator.java?rev=434193&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/CSVValidator.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/CSVValidator.java Wed Aug 23 14:34:27 2006
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+/**
+*
+* @author Lance Frohman
+*
+* @version $Revision: $ $Date: $
+*/
+
+public class CSVValidator 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 = ",";
+
+	// the VALIDATOR_ID of the actual validator to be used
+	protected String _subvalidatorId;
+
+	// the separator character to separate values
+	protected String _separator;
+
+	/**
+	 * @return the VALIDATOR_ID of the actual validator to be used
+	 */
+    public String getSubvalidatorId()
+    {
+    	return _subvalidatorId;
+    }
+
+	/**
+	 * @param the VALIDATOR_ID of the actual validator to be used
+	 */
+	public void setSubvalidatorId(String subvalidatorId) {
+		this._subvalidatorId = subvalidatorId;
+	}
+
+	/**
+	 * @return the separator character to separate values
+	 */
+	public String getSeparator() {
+		return _separator;
+	}
+
+	/**
+	 * @param the separator character to separate values
+	 */
+	public void setSeparator(String separator) {
+		this._separator = separator;
+	}
+
+	public Object saveState(FacesContext context) {
+		Object value[] = new Object[2];
+        value[0] = _subvalidatorId;
+        value[1] = _separator;
+		return value;
+	}
+
+	public void restoreState(FacesContext context, Object state) {
+        Object[] values = (Object[]) state;
+        _subvalidatorId = (String) values[0];
+        _separator = (String) values[1];
+	}
+
+	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(_subvalidatorId);
+	    if (_separator == null)
+	    	_separator = DEFAULT_SEPARATOR;
+	    String[] values = null;
+	    try {
+			values = ((String)value).split(_separator);
+	    }
+	    catch (PatternSyntaxException e) {
+			Object[] args = { _separator };
+            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);
+	}
+}

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/ValidateCSVTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/ValidateCSVTag.java?rev=434193&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/ValidateCSVTag.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/ValidateCSVTag.java Wed Aug 23 14:34:27 2006
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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 javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.validator.Validator;
+import javax.faces.webapp.UIComponentTag;
+import javax.servlet.jsp.JspException;
+import org.apache.myfaces.validator.ValidatorBaseTag;
+
+/**
+*
+* @author Lance Frohman
+*
+* @version $Revision: $ $Date: $
+*/
+
+public class ValidateCSVTag extends ValidatorBaseTag
+{
+    private static final long serialVersionUID = 1L;
+    private String _subvalidatorId;
+    private String _separator;
+
+    public void setSubvalidatorId(String subvalidatorId)
+    {
+        this._subvalidatorId = subvalidatorId;
+    }
+
+    public void setSeparator(String separator)
+    {
+        this._separator = separator;
+    }
+
+    protected Validator createValidator( ) throws JspException
+    {
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        setValidatorId(CSVValidator.VALIDATOR_ID);
+        CSVValidator validator = (CSVValidator)super.createValidator();
+        if (UIComponentTag.isValueReference(_subvalidatorId))
+        {
+            ValueBinding vb = facesContext.getApplication().createValueBinding(_subvalidatorId);
+            validator.setSubvalidatorId(new String(vb.getValue(facesContext).toString()));
+        }
+        else
+        {
+            validator.setSubvalidatorId(_subvalidatorId);
+        }
+        if (_separator != null)
+        {
+            if (UIComponentTag.isValueReference(_separator))
+            {
+                ValueBinding vb = facesContext.getApplication().createValueBinding(_separator);
+                validator.setSeparator(new String(vb.getValue(facesContext).toString()));
+            }
+            else
+            {
+                validator.setSeparator(_separator);
+            }
+        }
+        return validator;
+    }
+
+    public void release()
+    {
+        super.release();
+        _subvalidatorId= null;
+        _separator= null;
+    }
+
+}

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml?rev=434193&r1=434192&r2=434193&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml Wed Aug 23 14:34:27 2006
@@ -437,5 +437,9 @@
       <validator-id>org.apache.myfaces.validator.CompareTo</validator-id>
       <validator-class>org.apache.myfaces.custom.comparetovalidator.CompareToValidator</validator-class>
   </validator>
+  <validator>
+      <validator-id>org.apache.myfaces.validator.csv</validator-id>
+      <validator-class>org.apache.myfaces.custom.csvvalidator.CSVValidator</validator-class>
+  </validator>
 
 </faces-config>

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/csvvalidator_attributes.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/csvvalidator_attributes.xml?rev=434193&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/csvvalidator_attributes.xml (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/entities/csvvalidator_attributes.xml Wed Aug 23 14:34:27 2006
@@ -0,0 +1,10 @@
+<attribute>
+    <name>subvalidatorId</name>
+    <required>true</required>
+    <rtexprvalue>false</rtexprvalue>
+</attribute>
+<attribute>
+    <name>separator</name>
+    <required>false</required>
+    <rtexprvalue>false</rtexprvalue>
+</attribute>

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld?rev=434193&r1=434192&r2=434193&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Wed Aug 23 14:34:27 2006
@@ -134,6 +134,7 @@
 <!ENTITY ui_convertNumber_attributes SYSTEM "entities/ui_convertNumber_attributes.xml">
 <!ENTITY xml_template_attributes SYSTEM "entities/xml_template_attributes.xml">
 <!ENTITY select_items_attributes SYSTEM "entities/select_items_attributes.xml">
+<!ENTITY csvvalidator_attributes SYSTEM "entities/csvvalidator_attributes.xml">
 ]>
 
 
@@ -1201,5 +1202,15 @@
             <description>Comma or Space seperated List of ids from ui_command-items which trigger
             a partial update of this PanelGroup</description>
         </attribute>
+	</tag>
+
+	<!-- Validator for csv validation items -->
+	<tag>
+		<name>validateCSV</name>
+		<tag-class>org.apache.myfaces.custom.csvvalidator.ValidateCSVTag</tag-class>
+		<body-content>JSP</body-content>
+		<description>Validation by validating comma separated values individually.</description>
+        &ext_validator_base_attributes;
+		&csvvalidator_attributes;
 	</tag>
 </taglib>

Added: myfaces/tomahawk/trunk/sandbox/core/src/site/xdoc/CSVvalidator.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/site/xdoc/CSVvalidator.xml?rev=434193&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/site/xdoc/CSVvalidator.xml (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/site/xdoc/CSVvalidator.xml Wed Aug 23 14:34:27 2006
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+      
+        <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation Maven//EN" "http://maven.apache.org/dtd/maven-xdoc.dtd">
+      
+    <!--
+This is a standard template meant to be used for the documentation of all custom
+components.
+--><document>
+
+    <body>
+        <!-- Description -->
+        <section name="Description">
+            
+            <p>
+                Validate by separating comma (or custom separator) separated values and validating them individually
+            </p>
+        </section>
+        <!-- screen shot -->
+        <section name="Screen Shot">
+            
+            <p>Not Available</p> <!-- replace with either a figure or Not Available -->
+        </section>
+        <!-- API -->
+        <section name="API">
+            
+            <table>
+                <tr>
+                    <td colspan="1" rowspan="1">validatorId</td>
+                    <td colspan="1" rowspan="1">org.apache.myfaces.validator.csv</td>
+                </tr>
+                <tr>
+                    <td colspan="1" rowspan="1">validator-class</td>
+                    <td colspan="1" rowspan="1">org.apache.myfaces.custom.csvvalidator.CSVValidator</td>
+                </tr>
+                <tr>
+                    <td colspan="1" rowspan="1">tag-class</td>
+                    <td colspan="1" rowspan="1">org.apache.myfaces.custom.csvvalidator.ValidateCSVTag</td>
+                </tr>
+            </table>
+        </section>
+
+        <!-- Usage -->
+        <section name="Usage">
+            
+            <source xml:space="preserve">
+			&lt;h:inputText id="creditCardNumber" value="#{validateForm.creditCardNumber}" required="true"&gt;
+				&lt;s:validateCSV subvalidatorId="org.apache.myfaces.validator.CreditCard" separator="\\." /&gt;
+			&lt;/h:inputText&gt;
+			</source>
+        </section>
+        
+        <!-- Syntax -->
+        <section name="Syntax">
+            
+            <blockquote><h3>&lt;s:validateCSV/&gt;</h3>
+                <code>subvalidatorId - Required validator ID of actual validator.</code><br/>
+                <code>separator = Optional custom separator (default is ,)</code><br/>
+            </blockquote>
+        </section>
+        
+        <!-- Instructions -->
+        <section name="Instructions">
+            
+            <p>
+				Use this validator to allow users to enter multiple input values in a single input,
+				separated by a comma, semicolon, or other custome separator. The CSVValidator will
+				separate the input values and call the subvalidator for each of those values.
+            </p>
+            <p>See "myfaces-example-sandbox/validatecsv.jsp" for an example.</p>
+        </section>
+
+        <!-- Additional Information -->
+        <section name="Known issues">
+            
+            <p>
+				The separator, if specified, must be a valid regex for separating the input String, eq "\\."
+           </p>
+            <p>
+				Parameters cannot be passed.
+            </p>
+        </section>        
+
+    </body>
+    
+
+</document>

Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/validate/ValidateForm.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/validate/ValidateForm.java?rev=434193&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/validate/ValidateForm.java (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/validate/ValidateForm.java Wed Aug 23 14:34:27 2006
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.examples.validate;
+
+/**
+ * @author mwessendorf
+ * @version $Revision: 233386 $ $Date: 2005-08-18 14:57:01 -0700 (Thu, 18 Aug 2005) $
+ */
+public class ValidateForm {
+
+	private String email = null;
+	private String email2 = null;
+	private String creditCardNumber = null;
+	private String url = null;
+	private String regExpr = null;
+
+	private String equal = null;
+	private String equal2 = null;
+
+	private String isbn =null;
+
+
+	public String getEmail() {
+		return email;
+	}
+
+	public void setEmail(String string) {
+		email = string;
+	}
+
+	public String submit(){
+		System.out.println("Action was called.");
+		return ("valid");
+	}
+
+	public String getCreditCardNumber() {
+		return creditCardNumber;
+	}
+	public String getUrl(){
+		return url;
+	}
+	public void setCreditCardNumber(String string) {
+		creditCardNumber = string;
+	}
+	public void setUrl(String string) {
+		url = string;
+	}
+
+	public String getEmail2() {
+		return email2;
+	}
+
+	public void setEmail2(String string) {
+		email2 = string;
+	}
+
+	/**
+	 * @return
+	 */
+	public String getRegExpr() {
+		return regExpr;
+	}
+
+	/**
+	 * @param string
+	 */
+	public void setRegExpr(String string) {
+		regExpr = string;
+	}
+
+	/**
+	 * @return
+	 */
+	public String getEqual2() {
+		return equal2;
+	}
+
+	/**
+	 * @param string
+	 */
+	public void setEqual2(String string) {
+		equal2 = string;
+	}
+
+	/**
+	 * @return
+	 */
+	public String getEqual() {
+		return equal;
+	}
+
+	/**
+	 * @param string
+	 */
+	public void setEqual(String string) {
+		equal = string;
+	}
+
+    public String getIsbn() {
+        return isbn;
+    }
+    public void setIsbn(String isbn) {
+        this.isbn = isbn;
+    }
+}

Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties?rev=434193&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties Wed Aug 23 14:34:27 2006
@@ -0,0 +1,13 @@
+button_submit = Submit
+org.apache.myfaces.csv.NOT_STRING=The value {0} is not a String
+org.apache.myfaces.csv.SUFFIX= - on entry #{0}
+org.apache.myfaces.csv.INVALID_SEPARATOR=invalid separator {0}
+email_comma = Email separated by ,
+credit_dot = Credit Card separated by .
+url_comma = Url separated by ,
+isbn_semicolon = ISBN separated by ;
+validate_email = Email
+validate_credit = Credit Card
+validate_url = Url
+validate_regexp = Regular Expression
+validate_isbn = ISBN

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml?rev=434193&r1=434192&r2=434193&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/WEB-INF/examples-config.xml Wed Aug 23 14:34:27 2006
@@ -478,6 +478,13 @@
 		<managed-bean-scope>request</managed-bean-scope>
 	</managed-bean>
 
+	<!-- validation -->
+    <managed-bean>
+        <managed-bean-name>validateForm</managed-bean-name>
+        <managed-bean-class>org.apache.myfaces.examples.validate.ValidateForm</managed-bean-class>
+        <managed-bean-scope>request</managed-bean-scope>
+    </managed-bean>
+
 	<!-- navigation rules -->
     <navigation-rule>
 		<navigation-case>

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp?rev=434193&r1=434192&r2=434193&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp Wed Aug 23 14:34:27 2006
@@ -46,6 +46,7 @@
 	            	<h:outputLink value="validateUrl.jsf" ><f:verbatim>Validation example 2 - including URL validator</f:verbatim></h:outputLink>
 	            	<h:outputLink value="validateCompareTo.jsf" ><f:verbatim>validateCompareTo - Compare values on two different components</f:verbatim></h:outputLink>
 	            	<h:outputLink value="subForm.jsf"><f:verbatim>SubForm - Partial validation and model update with SubForms</f:verbatim></h:outputLink>
+	            	<h:outputLink value="validateCSV.jsf"><f:verbatim>CSVValidator - validate comma separated values with a given (sub)validator</f:verbatim></h:outputLink>
 	            </h:panelGrid>
 
             </h:panelGrid>

Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/validateCSV.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/validateCSV.jsp?rev=434193&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/validateCSV.jsp (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/validateCSV.jsp Wed Aug 23 14:34:27 2006
@@ -0,0 +1,72 @@
+<%@ page session="false" contentType="text/html;charset=utf-8"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
+<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s"%>
+
+<html>
+
+<%@include file="inc/head.inc" %>
+
+<!--
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+//-->
+
+<body>
+
+<!--
+managed beans used:
+    validateForm
+-->
+
+<f:view>
+
+    <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
+
+    <h:panelGroup id="body">
+
+	<h:form id="form1">
+		<h:panelGrid columns="3">
+		
+			<h:outputLabel for="email" value="#{example_messages['email_comma']}" />
+			<h:inputText id="email" value="#{validateForm.email}" required="true">
+				<s:validateCSV subvalidatorId="org.apache.myfaces.validator.Email" />
+			</h:inputText>
+			<t:message id="emailError" for="email" styleClass="error" />
+			
+			<h:outputLabel for="creditCardNumber" value="#{example_messages['credit_dot']}" />
+			<h:inputText id="creditCardNumber" value="#{validateForm.creditCardNumber}" required="true">
+				<s:validateCSV subvalidatorId="org.apache.myfaces.validator.CreditCard" separator="\\." />
+			</h:inputText>
+			<t:message id="creditCardNumberError" for="creditCardNumber" styleClass="error" />
+			
+			<h:panelGroup/>
+			<h:commandButton id="validateButton" value="#{example_messages['button_submit']}" action="#{validateForm.submit}"/>
+			<h:panelGroup/>
+		
+		</h:panelGrid>
+	</h:form>
+
+    </h:panelGroup>
+
+</f:view>
+
+<%@include file="inc/page_footer.jsp" %>
+
+</body>
+
+</html>