Author: ilya_shaikovsky
Date: 2008-08-01 08:48:40 -0400 (Fri, 01 Aug 2008)
New Revision: 9860
Added:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/snippets/
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/snippets/validationBean.java
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/validation/PassTime.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/examples/jsfValidation.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/usage.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/examples/simple.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/usage.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/additionalValidation.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/hibernateValidation.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/usage.xhtml
Log:
validators descriptions
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/validation/PassTime.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/validation/PassTime.java 2008-08-01
11:38:29 UTC (rev 9859)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/validation/PassTime.java 2008-08-01
12:48:40 UTC (rev 9860)
@@ -14,7 +14,7 @@
}
@NotEmpty
- @Length(max=12, min=3)
+ @Length(max=15, min=3)
private String title;
@NotNull
@Min(0)
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/examples/jsfValidation.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/examples/jsfValidation.xhtml 2008-08-01
11:38:29 UTC (rev 9859)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/examples/jsfValidation.xhtml 2008-08-01
12:48:40 UTC (rev 9860)
@@ -15,7 +15,7 @@
<h:outputText value="Name:" />
<h:inputText value="#{userBean.name}" id="name"
required="true">
<f:validateLength minimum="3" maximum="12"/>
- <rich:ajaxValidator event="onblur" ajaxSingle="true" />
+ <rich:ajaxValidator event="onblur"/>
</h:inputText>
<rich:message for="name" />
@@ -23,7 +23,7 @@
<h:inputText value="#{userBean.age}" id="age"
required="true">
<f:convertNumber integerOnly="true"/>
<f:validateLongRange minimum="18" maximum="99"/>
- <rich:ajaxValidator event="onblur" ajaxSingle="true" />
+ <rich:ajaxValidator event="onblur"/>
</h:inputText>
<rich:message for="age"/>
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/usage.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/usage.xhtml 2008-08-01
11:38:29 UTC (rev 9859)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxValidator/usage.xhtml 2008-08-01
12:48:40 UTC (rev 9860)
@@ -9,9 +9,15 @@
<ui:define name="sample">
<p>
- Using standard JSF validators
+ rich:ajaxValidator is a component designed in order to provide ajax validation
+ inside the inputs. It designed like a4j:support component but skips all JSF
processing
+ except validation.
</p>
-
+ <p>
+ Look to the first simple example. This component should be added as child component
+ to input which should be validated and specify validation event. The component
+ is ajaxSingle by default so only current field will be validated.
+ </p>
<fieldset class="demo_fieldset">
<legend class="demo_legend">Title</legend>
<div class="sample-container" >
@@ -22,8 +28,11 @@
</div>
</fieldset>
<p>
- Using Hibernate validators
+ The component also provide possibility to use Hibernate Validation for the target
fileds.
</p>
+ <p>
+ Look to the next examlpe which is modified in order to use Hibernate Validators:
+ </p>
<fieldset class="demo_fieldset">
<legend class="demo_legend">Title</legend>
<div class="sample-container" >
@@ -33,10 +42,10 @@
<ui:param name="openlabel" value="View Page Source" />
</ui:include>
<ui:include src="/templates/include/sourceview.xhtml">
- <ui:param name="sourcepath"
value="/WEB-INF/src/org/richfaces/demo/validator/ValidatorBean.java"/>
- <ui:param name="openlabel" value="View ValidatorBean.java
Source" />
+ <ui:param name="openlabel" value="Validation Bean Code"
/>
<ui:param name="sourcetype" value="java" />
- </ui:include>
+ <ui:param name="sourcepath"
value="/richfaces/beanValidator/snippets/validationBean.java"/>
+ </ui:include>
</div>
</fieldset>
</ui:define>
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/examples/simple.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/examples/simple.xhtml 2008-08-01
11:38:29 UTC (rev 9859)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/examples/simple.xhtml 2008-08-01
12:48:40 UTC (rev 9860)
@@ -13,7 +13,7 @@
<h:panelGrid columns="3">
<h:outputText value="Name:" />
<h:inputText value="#{validationBean.name}" id="name">
- <rich:ajaxValidator/>
+ <rich:beanValidator/>
</h:inputText>
<rich:message for="name" />
<h:outputText value="Email:" />
Added:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/snippets/validationBean.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/snippets/validationBean.java
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/snippets/validationBean.java 2008-08-01
12:48:40 UTC (rev 9860)
@@ -0,0 +1,49 @@
+package org.richfaces.demo.validation;
+
+import org.hibernate.validator.Email;
+import org.hibernate.validator.Length;
+import org.hibernate.validator.Max;
+import org.hibernate.validator.Min;
+import org.hibernate.validator.NotEmpty;
+import org.hibernate.validator.NotNull;
+
+public class ValidationBean {
+
+ @NotEmpty
+ @Length(min=3,max=12)
+ private String name;
+ @Email
+ @NotEmpty
+ private String email;
+ @NotNull
+ @Min(18)
+ @Max(100)
+ private int age;
+
+ public ValidationBean() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+}
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/usage.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/usage.xhtml 2008-08-01
11:38:29 UTC (rev 9859)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/usage.xhtml 2008-08-01
12:48:40 UTC (rev 9860)
@@ -9,19 +9,30 @@
<ui:define name="sample">
<p>
- Description
+ Starting from 3.2.2 GA version Rich Faces provides support for model-based
+ constraints defined using Hibernate Validator. So it's possible to use Hibernate
+ Validators the same as for Seam based applications.
</p>
-
+ <p>
+ rich:beanValidator component should be defined in the same way
+ as any JSF validators.
+ Lock through the example below.
+ </p>
<fieldset class="demo_fieldset">
<legend class="demo_legend">Title</legend>
<div class="sample-container" >
<ui:include src="/richfaces/beanValidator/examples/simple.xhtml"/>
<ui:include src="/templates/include/sourceview.xhtml">
+ <ui:param name="openlabel" value="Page Code" />
<ui:param name="sourcepath"
value="/richfaces/beanValidator/examples/simple.xhtml"/>
</ui:include>
+ <ui:include src="/templates/include/sourceview.xhtml">
+ <ui:param name="openlabel" value="Validation Bean Code"
/>
+ <ui:param name="sourcetype" value="java" />
+ <ui:param name="sourcepath"
value="/richfaces/beanValidator/snippets/validationBean.java"/>
+ </ui:include>
</div>
</fieldset>
</ui:define>
-
</ui:composition>
</html>
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/additionalValidation.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/additionalValidation.xhtml 2008-08-01
11:38:29 UTC (rev 9859)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/additionalValidation.xhtml 2008-08-01
12:48:40 UTC (rev 9860)
@@ -21,11 +21,8 @@
</rich:inputNumberSpinner>
<rich:message for="time" />
</rich:column>
- <rich:column>
- <h:outputText value="#{pt.title}" id="out"/>
- </rich:column>
</rich:dataTable>
</rich:graphValidator>
- <h:commandButton value="Store my details" />
+ <a4j:commandButton value="Store my details"
action="#{pt.store}"/>
</h:form>
</ui:composition>
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/hibernateValidation.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/hibernateValidation.xhtml 2008-08-01
11:38:29 UTC (rev 9859)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/hibernateValidation.xhtml 2008-08-01
12:48:40 UTC (rev 9860)
@@ -13,7 +13,9 @@
<rich:graphValidator>
<h:panelGrid columns="3">
<h:outputText value="Name:" />
- <h:inputText value="#{validationBean.name}" id="name"/>
+ <h:inputText value="#{validationBean.name}" id="name">
+ <f:validateLength minimum="2"/>
+ </h:inputText>
<rich:message for="name" />
<h:outputText value="Email:" />
<h:inputText value="#{validationBean.email}" id="email"/>
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/usage.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/usage.xhtml 2008-08-01
11:38:29 UTC (rev 9859)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/usage.xhtml 2008-08-01
12:48:40 UTC (rev 9860)
@@ -9,9 +9,15 @@
<ui:define name="sample">
<p>
- Description
+ Graph validator component also allow to register Hibernate Validators for the
+ input components. As opposite to beanValidator which should be
+ child component for the input to be validated this component should wrap
+ some subtree with inputs. As result validator for every input in this
+ subtree will be added to component.
</p>
-
+ <p>
+ Look through the next simple example:
+ </p>
<fieldset class="demo_fieldset">
<legend class="demo_legend">Title</legend>
<div class="sample-container" >
@@ -19,21 +25,38 @@
<ui:include src="/templates/include/sourceview.xhtml">
<ui:param name="sourcepath"
value="/richfaces/graphValidator/examples/hibernateValidation.xhtml"/>
</ui:include>
+ <ui:include src="/templates/include/sourceview.xhtml">
+ <ui:param name="openlabel" value="Validation Bean Code"
/>
+ <ui:param name="sourcetype" value="java" />
+ <ui:param name="sourcepath"
value="/richfaces/beanValidator/snippets/validationBean.java"/>
+ </ui:include>
</div>
</fieldset>
<p>
- Description
+ There is one additional usefull feature in Graph Validator component.
+ Value attribute could be defined with some value binding to bean. And the
+ bean properties will be validated again <b>after</b> model update.
</p>
-
+ <p>
+ Simple example of such usage below. Just write some activities of the day
+ and the time you spend to each one in a day.
+ </p>
<fieldset class="demo_fieldset">
<legend class="demo_legend">Title</legend>
- <div class="sample-container" >
+ <div class="sample-container">
<ui:include
src="/richfaces/graphValidator/examples/additionalValidation.xhtml"/>
<ui:include src="/templates/include/sourceview.xhtml">
<ui:param name="sourcepath"
value="/richfaces/graphValidator/examples/additionalValidation.xhtml"/>
</ui:include>
</div>
</fieldset>
+ <p>
+ In this case only properties of each passTime(values of the inputs) validated
+ at validation phase.
+ But after the model updated (Each explicit passtime was validated ok) all the
+ properties including "TotalTime" validated again. And total validation
could
+ fails if the sum of the hours in a day more than 24.
+ </p>
</ui:define>
</ui:composition>
Show replies by date