Author: ilya_shaikovsky
Date: 2011-01-31 06:35:34 -0500 (Mon, 31 Jan 2011)
New Revision: 21315
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/validation/DayStatistics.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/validation/PassTime.java
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/graphValidator.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/samples/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/samples/graphValidator-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/message/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/message/message.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/message/samples/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/message/samples/message-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/messages/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/messages/messages.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/messages/samples/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/messages/samples/messages-sample.xhtml
Modified:
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
Log:
https://issues.jboss.org/browse/RF-9257
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/validation/DayStatistics.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/validation/DayStatistics.java
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/validation/DayStatistics.java 2011-01-31
11:35:34 UTC (rev 21315)
@@ -0,0 +1,62 @@
+/**
+ *
+ */
+package org.richfaces.demo.validation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Ilya Shaikovsky
+ *
+ */
+@ManagedBean
+@RequestScoped
+public class DayStatistics {
+
+ public DayStatistics() {
+ dayPasstimes.add(new PassTime("Sport", 0));
+ dayPasstimes.add(new PassTime("Entertainment", 0));
+ dayPasstimes.add(new PassTime("Sleeping", 0));
+ dayPasstimes.add(new PassTime("Games", 0));
+ }
+
+ private List<PassTime> dayPasstimes = new ArrayList<PassTime>();
+
+ public List<PassTime> getDayPasstimes() {
+ return dayPasstimes;
+ }
+
+ public void setDayPasstimes(List<PassTime> dayPasstimes) {
+ this.dayPasstimes = dayPasstimes;
+ }
+
+ @NotNull
+ @Min(value = 1, message = "Please feel at list one entry")
+ @Max(value = 24, message = "Only 24h in a day!")
+ public Integer getTotalTime() {
+ Integer result = new Integer(0);
+ for (PassTime passtime : dayPasstimes) {
+ result += passtime.getTime();
+ }
+ return result;
+ }
+
+ public void store(ActionEvent event) {
+ FacesContext.getCurrentInstance().addMessage(
+ event.getComponent().getClientId(
+ FacesContext.getCurrentInstance()),
+ new FacesMessage(FacesMessage.SEVERITY_INFO,
+ "Changes Stored Successfully",
+ "Changes Stored Successfully"));
+ }
+}
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/validation/PassTime.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/validation/PassTime.java
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/validation/PassTime.java 2011-01-31
11:35:34 UTC (rev 21315)
@@ -0,0 +1,37 @@
+package org.richfaces.demo.validation;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+
+import org.hibernate.validator.constraints.Length;
+import org.hibernate.validator.constraints.NotEmpty;
+
+public class PassTime {
+
+ public PassTime(String title, Integer time) {
+ setTitle(title);
+ setTime(time);
+ }
+
+ @NotEmpty
+ @Length(max=15, min=3)
+ private String title;
+ @NotNull
+ @Min(0)
+ @Max(12)
+ private Integer time;
+ public String getTitle() {
+ return title;
+ }
+ public void setTitle(String title) {
+ this.title = title;
+ }
+ public Integer getTime() {
+ return time;
+ }
+ public void setTime(Integer time) {
+ this.time = time;
+ }
+
+}
Modified:
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2011-01-31
11:02:52 UTC (rev 21314)
+++
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2011-01-31
11:35:34 UTC (rev 21315)
@@ -189,6 +189,36 @@
</sample>
</samples>
</demo>
+ <!-- demo new="true">
+ <id>graphValidator</id>
+ <name>rich:graphValidator</name>
+ <samples>
+ <sample>
+ <id>graphValidator</id>
+ <name>Object validation using rich:graphValidator</name>
+ </sample>
+ </samples>
+ </demo-->
+ <demo new="true">
+ <id>message</id>
+ <name>rich:message</name>
+ <samples>
+ <sample>
+ <id>message</id>
+ <name>Simple rich:message sample</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>messages</id>
+ <name>rich:messages</name>
+ <samples>
+ <sample>
+ <id>messages</id>
+ <name>Simple rich:messages sample</name>
+ </sample>
+ </samples>
+ </demo>
</demos>
</group>
<group>
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/graphValidator.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/graphValidator.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/graphValidator.xhtml 2011-01-31
11:35:34 UTC (rev 21315)
@@ -0,0 +1,30 @@
+<!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:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/samples/graphValidator-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/samples/graphValidator-sample.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/graphValidator/samples/graphValidator-sample.xhtml 2011-01-31
11:35:34 UTC (rev 21315)
@@ -0,0 +1,49 @@
+<!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">
+ <a4j:region renderRegionOnly="true">
+ <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" /></td>
+ </tr>
+ </a4j:repeat>
+ </tbody>
+ </table>
+ </rich:graphValidator>
+ <a4j:commandButton value="Store my details"
+ actionListener="#{dayStatistics.store}" reRender="panel" />
+ <rich:messages infoClass="green" errorClass="red" />
+ </a4j:region>
+ </h:form>
+</ui:composition>
\ No newline at end of file
Added: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/message/message.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/message/message.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/message/message.xhtml 2011-01-31
11:35:34 UTC (rev 21315)
@@ -0,0 +1,34 @@
+<!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:message is an extension for a standard h:message component.
+ In addition to what the standard component provides, rich:message:</p>
+ <ul>
+ <li>does not require to be wrapped with a4j:outputPanel in order
+ to be rendered during the Ajax requests</li>
+ <li>allows to define different "failed" markers before the text
+ labels</li>
+ <li>has a predefined css class names for different kinds of
+ message severities</li>
+ </ul>
+ <p>The message marker is defined with a facet. There are several
+ facets names available to design the marker for different kind of
+ message severities. The following example shows how the markers might
+ be used to mark the "passed" and "failed" form fields. Fill the
form
+ and click "Validate" button to see the entered data passing the defined
+ validation rules.</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:composition>
+</html>
\ No newline at end of file
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/message/samples/message-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/message/samples/message-sample.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/message/samples/message-sample.xhtml 2011-01-31
11:35:34 UTC (rev 21315)
@@ -0,0 +1,72 @@
+<!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 type="text/css">
+.rich-message-marker img {
+ padding-right: 7px;
+}
+
+.rich-message-label {
+ color: red;
+}
+</style>
+ <rich:panel>
+ <f:facet name="header">
+ <h:outputText value="Validation Form" />
+ </f:facet>
+ <h:form>
+ <h:panelGrid columns="3">
+ <h:outputText value="Name:" />
+ <h:inputText label="Name" id="name" required="true"
+ value="#{userBean.name}">
+ <f:validateLength minimum="3" />
+ </h:inputText>
+ <rich:message for="name" showDetails="true"
showSummary="true">
+ <f:facet name="errorMarker">
+ <h:graphicImage value="/images/ajax/error.gif" />
+ </f:facet>
+ </rich:message>
+
+ <h:outputText value="Job:" />
+ <h:inputText label="Job" id="job" required="true"
+ value="#{userBean.job}">
+ <f:validateLength minimum="3" maximum="50" />
+ </h:inputText>
+ <rich:message for="job">
+ <f:facet name="errorMarker">
+ <h:graphicImage value="/images/ajax/error.gif" />
+ </f:facet>
+ </rich:message>
+ <h:outputText value="Address:" />
+ <h:inputText label="Address" id="address"
required="true"
+ value="#{userBean.address}">
+ <f:validateLength minimum="10" />
+ </h:inputText>
+ <rich:message for="address">
+ <f:facet name="errorMarker">
+ <h:graphicImage value="/images/ajax/error.gif" />
+ </f:facet>
+ </rich:message>
+ <h:outputText value="Zip:" />
+ <h:inputText label="Zip" id="zip" required="true"
+ value="#{userBean.zip}">
+ <f:validateLength minimum="4" maximum="9" />
+ </h:inputText>
+ <rich:message for="zip">
+ <f:facet name="errorMarker">
+ <h:graphicImage value="/images/ajax/error.gif" />
+ </f:facet>
+ </rich:message>
+ <f:facet name="footer">
+ <a4j:commandButton value="Ajax Validate" />
+ <h:commandButton value="Common Validate" />
+ </f:facet>
+ </h:panelGrid>
+ </h:form>
+ </rich:panel>
+</ui:composition>
\ No newline at end of file
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/messages/messages.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/messages/messages.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/messages/messages.xhtml 2011-01-31
11:35:34 UTC (rev 21315)
@@ -0,0 +1,34 @@
+<!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:messages is an extension for a standard h:messages
+ component. In addition to what the standard component provides,
+ rich:messages:</p>
+ <ul>
+ <li>does not require to be wrapped with a4j:outputPanel in order
+ to be rendered during the Ajax requests</li>
+ <li>allows to define different "failed" markers before the text
+ labels</li>
+ <li>has a predefined css class names for different kinds of
+ messages severities</li>
+ </ul>
+ <p>The message markers is defined with facets. There are several
+ facets names available to design the marker for different kind of
+ messages severities. The following example shows how the markers might
+ be used to mark the "passed" and "failed" form fields. Fill the
form
+ and click the "Validate" button to see the entered data passing the
+ defined validation rules.</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:composition>
+</html>
\ No newline at end of file
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/messages/samples/messages-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/messages/samples/messages-sample.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/messages/samples/messages-sample.xhtml 2011-01-31
11:35:34 UTC (rev 21315)
@@ -0,0 +1,70 @@
+<!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 type="text/css">
+.rich-messages-marker img {
+ padding-right: 7px;
+}
+
+.rich-message-label {
+ color: red;
+}
+
+.top {
+ vertical-align: top;
+}
+</style>
+<a4j:region>
+ <rich:panel style="width:400px">
+ <f:facet name="header">
+ <h:outputText value="Validation Form" />
+ </f:facet>
+
+ <h:form>
+ <rich:messages passedLabel="Data is allowed to be stored."
+ layout="list" showSummary="true"
showDetails="true">
+ <f:facet name="header">
+ <h:outputText value="Entered Data Status:"></h:outputText>
+ </f:facet>
+ <f:facet name="passedMarker">
+ <h:graphicImage value="/images/ajax/passed.gif" />
+ </f:facet>
+ <f:facet name="errorMarker">
+ <h:graphicImage value="/images/ajax/error.gif" />
+ </f:facet>
+ </rich:messages>
+
+ <h:panelGrid columns="2">
+ <h:outputText value="Name:" />
+ <h:inputText label="Name" id="name" required="true"
+ value="#{userBean.name}">
+ <f:validateLength minimum="3" />
+ </h:inputText>
+ <h:outputText value="Job:" />
+ <h:inputText label="Job" id="job" required="true"
+ value="#{userBean.job}">
+ <f:validateLength minimum="3" maximum="50" />
+ </h:inputText>
+ <h:outputText value="Address:" />
+ <h:inputText label="Address" id="address"
required="true"
+ value="#{userBean.address}">
+ <f:validateLength minimum="10" />
+ </h:inputText>
+ <h:outputText value="Zip:" />
+ <h:inputText label="Zip" id="zip" required="true"
+ value="#{userBean.zip}">
+ <f:validateLength minimum="4" maximum="9" />
+ </h:inputText>
+ <f:facet name="footer">
+ <a4j:commandButton value="Ajax Validate"/>
+ <h:commandButton value="Common Validate"/>
+ </f:facet>
+ </h:panelGrid>
+ </h:form>
+ </rich:panel>
+</a4j:region>
+</ui:composition>
\ No newline at end of file