Author: ilya_shaikovsky
Date: 2008-08-06 06:37:08 -0400 (Wed, 06 Aug 2008)
New Revision: 9935
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/validation/DayStatistics.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/additionalValidation.xhtml
Log:
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/validation/DayStatistics.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/validation/DayStatistics.java 2008-08-06
10:36:46 UTC (rev 9934)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/validation/DayStatistics.java 2008-08-06
10:37:08 UTC (rev 9935)
@@ -6,21 +6,25 @@
import java.util.ArrayList;
import java.util.List;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
import org.hibernate.validator.Max;
import org.hibernate.validator.Min;
import org.hibernate.validator.NotNull;
/**
* @author Ilya Shaikovsky
- *
+ *
*/
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));
+ 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>();
@@ -32,16 +36,24 @@
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!")
+ @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();
+ 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"));
+ }
}
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-06
10:36:46 UTC (rev 9934)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/graphValidator/examples/additionalValidation.xhtml 2008-08-06
10:37:08 UTC (rev 9935)
@@ -5,25 +5,44 @@
xmlns:f="http://java.sun.com/jsf/core"
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="#{dayStatistics}">
- <rich:dataTable value="#{dayStatistics.dayPasstimes}" var="pt"
id="table">
- <rich:column>
- <h:inputText value="#{pt.title}" >
- <a4j:support reRender="out" event="onkeyup"/>
- </h:inputText>
- </rich:column>
- <rich:column>
- <rich:inputNumberSpinner minValue="0" maxValue="24"
- value="#{pt.time}" id="time">
- <rich:ajaxValidator event="onblur" />
- </rich:inputNumberSpinner>
- <rich:message for="time" />
- </rich:column>
- </rich:dataTable>
- <rich:messages />
+ <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:ajaxValidator event="onblur" />
+ </rich:inputNumberSpinner>
+ </td>
+ <td>
+ <rich:message for="time" />
+ </td>
+ </tr>
+ </a4j:repeat>
+ </tbody>
+ </table>
</rich:graphValidator>
- <a4j:commandButton value="Store my details"
action="#{pt.store}"/>
+ <a4j:commandButton value="Store my details"
actionListener="#{dayStatistics.store}" reRender="panel"/>
+ <rich:messages infoClass="green" errorClass="red"/>
</h:form>
</ui:composition>