Author: alexsmirnov
Date: 2010-09-28 14:03:59 -0400 (Tue, 28 Sep 2010)
New Revision: 19356
Added:
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/Bean.java
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/DataBean.java
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/GraphValidatorBean.java
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/LengthBean.java
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/MaxBean.java
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/MinBean.java
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/MinMaxBean.java
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/NotEmptyBean.java
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/NotNullBean.java
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/Validable.java
branches/RF-8742/examples/validator-demo/src/main/webapp/examples/ajaxValidation.xhtml
branches/RF-8742/examples/validator-demo/src/main/webapp/examples/beanValidation.xhtml
branches/RF-8742/examples/validator-demo/src/main/webapp/examples/graphValidation.xhtml
Modified:
branches/RF-8742/examples/validator-demo/pom.xml
Log:
import validator example code from 3.3.3
Modified: branches/RF-8742/examples/validator-demo/pom.xml
===================================================================
--- branches/RF-8742/examples/validator-demo/pom.xml 2010-09-28 16:43:40 UTC (rev 19355)
+++ branches/RF-8742/examples/validator-demo/pom.xml 2010-09-28 18:03:59 UTC (rev 19356)
@@ -39,14 +39,30 @@
<dependencies>
<dependency>
- <groupId>org.richfaces.ui.validator</groupId>
- <artifactId>richfaces-ui-validator-ui</artifactId>
- </dependency>
- <dependency>
<groupId>org.richfaces.examples</groupId>
<artifactId>template</artifactId>
<version>4.0.0-SNAPSHOT</version>
<type>war</type>
</dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.validator</groupId>
+ <artifactId>richfaces-ui-validator-ui</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.validator</groupId>
+ <artifactId>richfaces-ui-validator-impl</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.validator</groupId>
+ <artifactId>richfaces-ui-validator-api</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ <version>1.0.0.GA</version>
+ </dependency>
</dependencies>
</project>
Added:
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/Bean.java
===================================================================
---
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/Bean.java
(rev 0)
+++
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/Bean.java 2010-09-28
18:03:59 UTC (rev 19356)
@@ -0,0 +1,72 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.example;
+
+import javax.validation.constraints.Pattern;
+
+
+
+
+/**
+ * JSF bean with text property validation.
+ */
+public class Bean {
+
+ /**
+ * Text property
+ */
+ private String email;
+
+ private String creditCardNumber;
+
+ /**
+ * @return the creditCardNumber
+ */
+ @Pattern(regexp="\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d")
+ public String getCreditCardNumber() {
+ return creditCardNumber;
+ }
+
+ /**
+ * @param creditCardNumber the creditCardNumber to set
+ */
+ public void setCreditCardNumber(String creditCardNumber) {
+ this.creditCardNumber = creditCardNumber;
+ }
+
+ /**
+ * @return the text
+ */
+// @Email
+// @Pattern(regexp="^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9](a)[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$")
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * @param text the text to set
+ */
+ public void setEmail(String text) {
+ this.email = text;
+ }
+
+}
\ No newline at end of file
Added:
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/DataBean.java
===================================================================
---
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/DataBean.java
(rev 0)
+++
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/DataBean.java 2010-09-28
18:03:59 UTC (rev 19356)
@@ -0,0 +1,49 @@
+/**
+ *
+ */
+package org.richfaces.example;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.validation.Valid;
+import javax.validation.constraints.Max;
+
+
+/**
+ * @author asmirnov
+ *
+ */
+public class DataBean {
+
+ private final List<Validable> beans;
+
+ /**
+ * @return the beans
+ */
+ @Valid
+ public List<Validable> getBeans() {
+ return beans;
+ }
+
+ public DataBean() {
+ beans = new ArrayList<Validable>(6);
+ beans.add(new NotNullBean());
+ beans.add(new NotEmptyBean());
+ beans.add(new LengthBean());
+ beans.add(new MinBean());
+ beans.add(new MaxBean());
+ beans.add(new MinMaxBean());
+ }
+
+ @Max(value=20,message="Total value should be less then 20")
+ public int getTotal(){
+ int total = 0;
+ for (Validable bean : beans) {
+ total += bean.getIntValue();
+ }
+ return total;
+ }
+
+
+}
Added:
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/GraphValidatorBean.java
===================================================================
---
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/GraphValidatorBean.java
(rev 0)
+++
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/GraphValidatorBean.java 2010-09-28
18:03:59 UTC (rev 19356)
@@ -0,0 +1,99 @@
+/**
+ *
+ */
+package org.richfaces.example;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+
+
+/**
+ * @author asmirnov
+ *
+ */
+public class GraphValidatorBean implements Cloneable {
+
+ @Min(0)
+ @Max(10)
+ private int first ;
+
+ @Min(value=5,message="Value {0} should be more than {value}")
+ @Max(15)
+ private int second ;
+
+ @Min(0)
+ @Max(20)
+ private int third ;
+
+ private String actionResult;
+
+ /**
+ * @return the actionResult
+ */
+ public String getActionResult() {
+ return actionResult;
+ }
+
+ /**
+ * @param actionResult the actionResult to set
+ */
+ public void setActionResult(String actionResult) {
+ this.actionResult = actionResult;
+ }
+
+ /**
+ * @return the first
+ */
+ public int getFirst() {
+ return first;
+ }
+
+ /**
+ * @param first the first to set
+ */
+ public void setFirst(int first) {
+ this.first = first;
+ }
+
+ /**
+ * @return the second
+ */
+ public int getSecond() {
+ return second;
+ }
+
+ /**
+ * @param second the second to set
+ */
+ public void setSecond(int second) {
+ this.second = second;
+ }
+
+ /**
+ * @return the third
+ */
+ public int getThird() {
+ return third;
+ }
+
+ /**
+ * @param third the third to set
+ */
+ public void setThird(int third) {
+ this.third = third;
+ }
+
+ /**
+ * @return total summ of the list values.
+ */
+ @Max(value=20,message="Total value should be less then 20")
+ public int getSumm(){
+ return first+second+third;
+ }
+
+ public String action() {
+ // Persist your data here
+ setActionResult("Data have been saved");
+ return "ok";
+ }
+}
Added:
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/LengthBean.java
===================================================================
---
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/LengthBean.java
(rev 0)
+++
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/LengthBean.java 2010-09-28
18:03:59 UTC (rev 19356)
@@ -0,0 +1,64 @@
+/**
+ *
+ */
+package org.richfaces.example;
+
+import javax.validation.constraints.Size;
+
+
+/**
+ * @author asmirnov
+ *
+ */
+public class LengthBean implements Validable {
+
+ @Size(max=10,min=2,message="incorrect field length")
+ private String text;
+
+ private int intValue;
+
+ /**
+ * @return the text
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text the text to set
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * @return the intValue
+ */
+ public int getIntValue() {
+ return intValue;
+ }
+
+ /**
+ * @param intValue the intValue to set
+ */
+ public void setIntValue(int intValue) {
+ this.intValue = intValue;
+ }
+
+ public String getTextDescription() {
+ return "Validate String Length, for a range 2-10 chars";
+ }
+
+ public String getIntDescription() {
+ return "Integer Value, no restrictions";
+ }
+
+ public String getIntSummary() {
+ return "Invalid user name";
+ }
+
+ public String getTextSummary() {
+ return "Invalid user name";
+ }
+
+}
Added:
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/MaxBean.java
===================================================================
---
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/MaxBean.java
(rev 0)
+++
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/MaxBean.java 2010-09-28
18:03:59 UTC (rev 19356)
@@ -0,0 +1,69 @@
+/**
+ *
+ */
+package org.richfaces.example;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Pattern;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class MaxBean implements Validable {
+
+ private String text;
+
+ @Max(10)
+ private int intValue;
+
+ /**
+ * @return the text
+ */
+// @CreditCardNumber
+ @Pattern(regexp="\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d")
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text the text to set
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * @return the intValue
+ */
+ public int getIntValue() {
+ return intValue;
+ }
+
+ /**
+ * @param intValue the intValue to set
+ */
+ public void setIntValue(int intValue) {
+ this.intValue = intValue;
+ }
+
+ public String getTextDescription() {
+ return "Text value, should be correct credit card number";
+ }
+
+ public String getIntDescription() {
+ // TODO Auto-generated method stub
+ return "Integer Value, less then 10";
+ }
+
+ public String getIntSummary() {
+ // TODO Auto-generated method stub
+ return "Invalid number of items";
+ }
+
+ public String getTextSummary() {
+ // TODO Auto-generated method stub
+ return "Invalid payment card";
+ }
+
+}
Added:
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/MinBean.java
===================================================================
---
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/MinBean.java
(rev 0)
+++
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/MinBean.java 2010-09-28
18:03:59 UTC (rev 19356)
@@ -0,0 +1,66 @@
+/**
+ *
+ */
+package org.richfaces.example;
+
+import javax.validation.constraints.Min;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class MinBean implements Validable {
+
+ private String text;
+
+ @Min(2)
+ private int intValue;
+
+ /**
+ * @return the text
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text the text to set
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * @return the intValue
+ */
+ public int getIntValue() {
+ return intValue;
+ }
+
+ /**
+ * @param intValue the intValue to set
+ */
+ public void setIntValue(int intValue) {
+ this.intValue = intValue;
+ }
+
+ public String getTextDescription() {
+ return "Text value, no restrictions";
+ }
+
+ public String getIntDescription() {
+ // TODO Auto-generated method stub
+ return "Integer Value, more then 1";
+ }
+
+ public String getIntSummary() {
+ // TODO Auto-generated method stub
+ return "Invalid rooms qty";
+ }
+
+ public String getTextSummary() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added:
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/MinMaxBean.java
===================================================================
---
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/MinMaxBean.java
(rev 0)
+++
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/MinMaxBean.java 2010-09-28
18:03:59 UTC (rev 19356)
@@ -0,0 +1,68 @@
+/**
+ *
+ */
+package org.richfaces.example;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class MinMaxBean implements Validable {
+
+ private String text;
+
+ @Min(value=2,message="Value {0} should be more than {value}")
+ @Max(10)
+ private int intValue;
+
+ /**
+ * @return the text
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text the text to set
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * @return the intValue
+ */
+ public int getIntValue() {
+ return intValue;
+ }
+
+ /**
+ * @param intValue the intValue to set
+ */
+ public void setIntValue(int intValue) {
+ this.intValue = intValue;
+ }
+
+ public String getTextDescription() {
+ return "Text Value, no restrictions";
+ }
+
+ public String getIntDescription() {
+ // TODO Auto-generated method stub
+ return "Integer Value, valid values from 2 to 10";
+ }
+
+ public String getIntSummary() {
+ // TODO Auto-generated method stub
+ return "Invalid price";
+ }
+
+ public String getTextSummary() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added:
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/NotEmptyBean.java
===================================================================
---
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/NotEmptyBean.java
(rev 0)
+++
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/NotEmptyBean.java 2010-09-28
18:03:59 UTC (rev 19356)
@@ -0,0 +1,67 @@
+/**
+ *
+ */
+package org.richfaces.example;
+
+import javax.validation.constraints.Size;
+
+
+/**
+ * @author asmirnov
+ *
+ */
+public class NotEmptyBean implements Validable {
+
+ @Size(min=1)
+ private String text;
+
+ private int intValue;
+
+ /**
+ * @return the text
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text the text to set
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * @return the intValue
+ */
+ public int getIntValue() {
+ return intValue;
+ }
+
+ /**
+ * @param intValue the intValue to set
+ */
+ public void setIntValue(int intValue) {
+ this.intValue = intValue;
+ }
+
+ public String getTextDescription() {
+ return "Text value, Not Empty Validation";
+ }
+
+ public String getIntDescription() {
+ // TODO Auto-generated method stub
+ return "Integer Value, no restrictions";
+ }
+
+ public String getIntSummary() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getTextSummary() {
+ // TODO Auto-generated method stub
+ return "Invalid password";
+ }
+
+}
Added:
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/NotNullBean.java
===================================================================
---
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/NotNullBean.java
(rev 0)
+++
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/NotNullBean.java 2010-09-28
18:03:59 UTC (rev 19356)
@@ -0,0 +1,66 @@
+/**
+ *
+ */
+package org.richfaces.example;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class NotNullBean implements Validable {
+
+ @NotNull
+ private String text;
+
+ private int intValue;
+
+ /**
+ * @return the text
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text the text to set
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * @return the intValue
+ */
+ public int getIntValue() {
+ return intValue;
+ }
+
+ /**
+ * @param intValue the intValue to set
+ */
+ public void setIntValue(int intValue) {
+ this.intValue = intValue;
+ }
+
+ public String getTextDescription() {
+ return "Text Value, Not Null Validation";
+ }
+
+ public String getIntDescription() {
+ // TODO Auto-generated method stub
+ return "Integer Value, no restrictions";
+ }
+
+ public String getIntSummary() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getTextSummary() {
+ // TODO Auto-generated method stub
+ return "Invalid address";
+ }
+
+}
Added:
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/Validable.java
===================================================================
---
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/Validable.java
(rev 0)
+++
branches/RF-8742/examples/validator-demo/src/main/java/org/richfaces/example/Validable.java 2010-09-28
18:03:59 UTC (rev 19356)
@@ -0,0 +1,21 @@
+/**
+ *
+ */
+package org.richfaces.example;
+
+/**
+ * @author asmirnov
+ *
+ */
+public interface Validable {
+
+ public String getText();
+
+ public String getTextDescription();
+
+ public String getTextSummary();
+
+ public int getIntValue();
+
+ public String getIntSummary();
+}
Added:
branches/RF-8742/examples/validator-demo/src/main/webapp/examples/ajaxValidation.xhtml
===================================================================
---
branches/RF-8742/examples/validator-demo/src/main/webapp/examples/ajaxValidation.xhtml
(rev 0)
+++
branches/RF-8742/examples/validator-demo/src/main/webapp/examples/ajaxValidation.xhtml 2010-09-28
18:03:59 UTC (rev 19356)
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns:c="http://java.sun.com/jstl/core">
+<ui:composition template="/layout/template.xhtml">
+ <ui:param name="title" value="<rich:ajaxValidator>
usage" />
+ <ui:param name="javaBean" value="org/richfaces/example/Bean.java"
/>
+ <!-- Page header -->
+ <ui:define name="header">
+ <h1><rich:ajaxValidator> usage</h1>
+ </ui:define>
+ <!-- content -->
+ <ui:define name="content">
+ <h:form id="form">
+ <h:panelGrid columns="3">
+ <h:outputLabel for="email" value="Email Address:" />
+ <h:inputText id="email" value="#{bean.email}"
label="Email">
+ <rich:ajaxValidator event="onkeyup" summary="Invalid Email
address" profiles="javax.validation.groups.Default"/>
+ </h:inputText>
+ <rich:message for="email"/>
+ <h:outputLabel for="card" value="Credit card number:" />
+ <h:inputText id="card" value="#{bean.creditCardNumber}"
label="Credit card">
+ <rich:ajaxValidator event="onkeyup" summary="Invalid credit card
number" profiles="javax.validation.groups.Default"/>
+ </h:inputText>
+ <rich:message for="card"/>
+ </h:panelGrid>
+ <h:commandButton value="Submit"></h:commandButton>
+ <rich:messages/>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
branches/RF-8742/examples/validator-demo/src/main/webapp/examples/beanValidation.xhtml
===================================================================
---
branches/RF-8742/examples/validator-demo/src/main/webapp/examples/beanValidation.xhtml
(rev 0)
+++
branches/RF-8742/examples/validator-demo/src/main/webapp/examples/beanValidation.xhtml 2010-09-28
18:03:59 UTC (rev 19356)
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns:c="http://java.sun.com/jstl/core">
+<ui:composition template="/layout/template.xhtml">
+ <ui:param name="title" value="<rich:beanValidator>
usage" />
+ <ui:param name="javaBean" value="org/richfaces/example/Bean.java"
/>
+ <!-- Page header -->
+ <ui:define name="header">
+ <h1><rich:beanValidator> usage</h1>
+ </ui:define>
+ <!-- content -->
+ <ui:define name="content">
+ <h:form id="form">
+ <h:panelGrid columns="3">
+ <h:outputLabel for="email" value="Email Address:" />
+ <h:inputText id="email" value="#{bean.email}"
label="Email">
+ <rich:beanValidator summary="Invalid Email address" />
+ </h:inputText>
+ <rich:message for="email"/>
+ <h:outputLabel for="card" value="Credit card number:" />
+ <h:inputText id="card" value="#{bean.creditCardNumber}"
label="Credit card">
+ <rich:beanValidator summary="Invalid credit card number"
profiles="javax.validation.groups.Default"/>
+ </h:inputText>
+ <rich:message for="card"/>
+ </h:panelGrid>
+ <h:commandButton value="Submit"></h:commandButton>
+ <rich:messages/>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
Added:
branches/RF-8742/examples/validator-demo/src/main/webapp/examples/graphValidation.xhtml
===================================================================
---
branches/RF-8742/examples/validator-demo/src/main/webapp/examples/graphValidation.xhtml
(rev 0)
+++
branches/RF-8742/examples/validator-demo/src/main/webapp/examples/graphValidation.xhtml 2010-09-28
18:03:59 UTC (rev 19356)
@@ -0,0 +1,59 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns:c="http://java.sun.com/jstl/core">
+<ui:composition template="/layout/template.xhtml">
+ <ui:param name="title" value="<rich:graphValidator>
usage" />
+ <ui:param name="javaBean"
value="org/richfaces/example/GraphValidatorBean.java" />
+ <!-- Page header -->
+ <ui:define name="header">
+ <h1><rich:graphValidator> usage</h1>
+ </ui:define>
+ <!-- content -->
+ <ui:define name="description">
+ <p>In that sampe <rich:graphValidator> component appends
JSR-303 or Hibernate validators to all enclosed input components
+ that check restrictions for field values, and, in addition, validates whole
bean.</p>
+ <p>JSF bean fields are annotated with @Min/@Max restrictions and getter for
the 'total' attribute is also annotated by the @Max</p>
+ <p>As a result, even valid field values would make whole bean an invalid.
For example, values '2','7','15' are valid for fields values but
their sum exceed maximum total value '20'</p>
+ <p>Validator assignes new values to a cloned bean instance hence model is
not updated with invalid values.</p>
+ </ui:define>
+ <ui:define name="content">
+ <h:form id="form">
+ <rich:graphValidator value="#{graphValidatorBean}"
id="validator" profiles="javax.validation.groups.Default">
+ <h:panelGrid columns="4">
+ <h:outputText value=""/>
+ <h:outputText value="Input"/>
+ <h:outputText value="Message"/>
+ <h:outputText value="Model value"/>
+
+ <h:outputLabel for="value0" value="First value, integer from 0 to
10:" />
+ <h:inputText id="value0" value="#{graphValidatorBean.first}"
label="First" />
+ <rich:message for="value0"/>
+ <h:outputText value="#{graphValidatorBean.first}"/>
+
+ <h:outputLabel for="value1" value="Second value,integer from 5 to
15:" />
+ <h:inputText id="value1" value="#{graphValidatorBean.second}"
label="Second" />
+ <rich:message for="value1"/>
+ <h:outputText value="#{graphValidatorBean.second}"/>
+
+ <h:outputLabel for="value2" value="Third value,integer from 0 to
20:" />
+ <h:inputText id="value2" value="#{graphValidatorBean.third}"
label="Third" />
+ <rich:message for="value2"/>
+ <h:outputText value="#{graphValidatorBean.third}"/>
+
+ <h:outputLabel for="total" value="Total, should be no more then
20:" />
+ <h:outputText id="total"
value="#{graphValidatorBean.summ}"/>
+ </h:panelGrid>
+ <h:commandButton value="Submit"
action="#{graphValidatorBean.action}"></h:commandButton>
+ <h:outputText id="result"
value="#{graphValidatorBean.actionResult}"/>
+ </rich:graphValidator>
+ <rich:messages/>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file