Author: ilya_shaikovsky
Date: 2011-02-28 09:23:50 -0500 (Mon, 28 Feb 2011)
New Revision: 21978
Added:
branches/4.0.X/examples/richfaces-showcase/src/main/java/org/richfaces/demo/validation/PasswordValidationBean.java
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/passwordValidation.xhtml
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/samples/passwordValidation-sample.xhtml
Removed:
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/graphValidator.xhtml
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/samples/graphValidator-sample.xhtml
Modified:
branches/4.0.X/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
Log:
push demo updated with more easy and popular password validation demo
Added:
branches/4.0.X/examples/richfaces-showcase/src/main/java/org/richfaces/demo/validation/PasswordValidationBean.java
===================================================================
---
branches/4.0.X/examples/richfaces-showcase/src/main/java/org/richfaces/demo/validation/PasswordValidationBean.java
(rev 0)
+++
branches/4.0.X/examples/richfaces-showcase/src/main/java/org/richfaces/demo/validation/PasswordValidationBean.java 2011-02-28
14:23:50 UTC (rev 21978)
@@ -0,0 +1,43 @@
+package org.richfaces.demo.validation;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.context.FacesContext;
+import javax.validation.constraints.AssertTrue;
+import javax.validation.constraints.Size;
+
+@ManagedBean
+@SessionScoped
+public class PasswordValidationBean implements Cloneable{
+ @Size(min = 5, max = 15, message = "Wrong size for password")
+ private String password="";
+ @Size(min = 5, max = 15, message = "Wrong size for confirmation")
+ private String confirm="";
+
+ @AssertTrue(message = "Different passwords entered!")
+ public boolean isPasswordsEquals() {
+ return password.equals(confirm);
+ }
+
+ public void storeNewPassword() {
+ FacesContext.getCurrentInstance().addMessage(null,
+ new FacesMessage(FacesMessage.SEVERITY_INFO, "Succesfully
changed!", "Succesfully changed!"));
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public void setConfirm(String confirm) {
+ this.confirm = confirm;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String getConfirm() {
+ return confirm;
+ }
+}
Modified:
branches/4.0.X/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
---
branches/4.0.X/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2011-02-28
13:59:07 UTC (rev 21977)
+++
branches/4.0.X/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2011-02-28
14:23:50 UTC (rev 21978)
@@ -194,9 +194,13 @@
<name>rich:graphValidator</name>
<samples>
<sample>
- <id>graphValidator</id>
- <name>Object validation using rich:graphValidator</name>
+ <id>passwordValidation</id>
+ <name>Password Validation</name>
</sample>
+ <sample>
+ <id>dayStatisticValidation</id>
+ <name>Day pass-times validation</name>
+ </sample>
</samples>
</demo>
<demo>
Deleted:
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/graphValidator.xhtml
===================================================================
---
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/graphValidator.xhtml 2011-02-28
13:59:07 UTC (rev 21977)
+++
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/graphValidator.xhtml 2011-02-28
14:23:50 UTC (rev 21978)
@@ -1,30 +0,0 @@
-<!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:h="http://java.sun.com/jsf/html"
-
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:ui="http://java.sun.com/jsf/facelets">
-
-<ui:composition>
- <p>rich:graphValidator is a component which allows to perform
- Object validation. value attribute should be defined with the value
- binding to bean. In the result all the bean properties will be
- validated during validation phase. That allows you to validate all the
- object properties and not just ones which are submitted with the
- current request.</p>
-
- <p>Simple example of such kind of usage is shown below. Just write
- some activities of the day and the time you spend on each one in a day.</p>
- <ui:include src="#{demoNavigator.sampleIncludeURI}" />
- <ui:include src="/templates/includes/source-view.xhtml">
- <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}"
/>
- <ui:param name="sourceType" value="xhtml" />
- <ui:param name="openLabel" value="View Source" />
- <ui:param name="hideLabel" value="Hide Source" />
- </ui:include>
- <p>In this case only properties of each passTime(values of the
- inputs) is validated at validation phase. But after the model is
- updated (Each explicit passtime was validated ok) all the properties
- including "TotalTime" are validated again. And total validation could
- fail if the sum of the hours in a day more than 24.</p>
-</ui:composition>
-</html>
\ No newline at end of file
Added:
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/passwordValidation.xhtml
===================================================================
---
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/passwordValidation.xhtml
(rev 0)
+++
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/passwordValidation.xhtml 2011-02-28
14:23:50 UTC (rev 21978)
@@ -0,0 +1,35 @@
+<!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:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition>
+ <p><b>rich:graphValidator</b> is a component which allows to
+ perform Object validation. value attribute should be defined with the
+ value binding to bean. In the result all the bean properties will be
+ validated during validation phase. That allows you to validate all the
+ object properties and not just ones which are submitted with the
+ current request.</p>
+
+ <p>Simple but probably most common example of such kind of usage is
+ shown below. Below is the simple sample of <b>cross-field
+ validation</b>. Passwords getting validated according to constraints for
+ every field and <b>isPasswordEquals</b> validation check if them are
+ equals.</p>
+ <ui:include src="#{demoNavigator.sampleIncludeURI}" />
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}"
/>
+ <ui:param name="sourceType" value="xhtml" />
+ <ui:param name="openLabel" value="View Source" />
+ <ui:param name="hideLabel" value="Hide Source" />
+ </ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src"
+ value="/WEB-INF/src/org/richfaces/demo/validation/PasswordValidationBean.java"
/>
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View PasswordValidationBean
Source" />
+ <ui:param name="hideLabel" value="Hide PasswordValidationBean
Source" />
+ </ui:include>
+</ui:composition>
+</html>
\ No newline at end of file
Deleted:
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/samples/graphValidator-sample.xhtml
===================================================================
---
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/samples/graphValidator-sample.xhtml 2011-02-28
13:59:07 UTC (rev 21977)
+++
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/samples/graphValidator-sample.xhtml 2011-02-28
14:23:50 UTC (rev 21978)
@@ -1,48 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:a4j="http://richfaces.org/a4j"
-
xmlns:rich="http://richfaces.org/rich">
-
- <style>
-.red {
- color: red;
-}
-
-.green {
- color: green;
-}
-</style>
- <h:form id="graphValidatorForm2">
- <rich:graphValidator summary="Invalid values: "
- value="#{dayStatistics}">
- <table>
- <thead>
- <tr>
- <th>Activity</th>
- <th>Time</th>
- </tr>
- </thead>
- <tbody>
- <a4j:repeat value="#{dayStatistics.dayPasstimes}" var="pt"
- id="table">
- <tr>
- <td align="center" width="100px"><h:outputText
- value="#{pt.title}" /></td>
- <td align="center"
width="100px"><rich:inputNumberSpinner
- minValue="0" maxValue="24" value="#{pt.time}"
id="time">
- </rich:inputNumberSpinner></td>
- <td><rich:message for="time"
ajaxRendered="true"/></td>
- </tr>
- </a4j:repeat>
- </tbody>
- </table>
- </rich:graphValidator>
- <a4j:commandButton value="Store my details"
- actionListener="#{dayStatistics.store}" />
- <br />
- <rich:messages infoClass="green" errorClass="red"
ajaxRendered="true" />
- </h:form>
-</ui:composition>
\ No newline at end of file
Added:
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/samples/passwordValidation-sample.xhtml
===================================================================
---
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/samples/passwordValidation-sample.xhtml
(rev 0)
+++
branches/4.0.X/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/samples/passwordValidation-sample.xhtml 2011-02-28
14:23:50 UTC (rev 21978)
@@ -0,0 +1,36 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich">
+
+ <style>
+.red {
+ color: red;
+}
+
+.green {
+ color: green;
+}
+</style>
+ <h:form>
+ <rich:graphValidator value="#{passwordValidationBean}"
id="gv">
+ <rich:panel header="Change password" style="width:500px">
+ <rich:messages for="gv"/>
+ <rich:messages globalOnly="true"/>
+ <h:panelGrid columns="3">
+ <h:outputText value="Enter new password:" />
+ <h:inputSecret value="#{passwordValidationBean.password}"
id="pass" />
+ <rich:message for="pass" />
+ <h:outputText value="Confirm the new password:" />
+ <h:inputSecret value="#{passwordValidationBean.confirm}"
id="conf" />
+ <rich:message for="conf" />
+ </h:panelGrid>
+ <a4j:commandButton value="Store changes"
+ action="#{passwordValidationBean.storeNewPassword}" />
+ </rich:panel>
+ </rich:graphValidator>
+ </h:form>
+</ui:composition>
\ No newline at end of file