Author: ilya_shaikovsky
Date: 2007-10-16 06:02:47 -0400 (Tue, 16 Oct 2007)
New Revision: 3392
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/ajaxsupport/UserBean.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/poll/examples/clock.xhtml
Log:
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/ajaxsupport/UserBean.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/ajaxsupport/UserBean.java 2007-10-16
09:55:27 UTC (rev 3391)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/ajaxsupport/UserBean.java 2007-10-16
10:02:47 UTC (rev 3392)
@@ -11,6 +11,7 @@
private String city;
private String zip;
private Date date;
+ private Date pollStartTime;
private boolean pollEnabled;
public UserBean() {
@@ -60,7 +61,13 @@
}
public Date getDate() {
- return new Date();
+ Date date = new Date();
+ if (null==pollStartTime){
+ pollStartTime = new Date();
+ return date;
+ }
+ if ((date.getTime()-pollStartTime.getTime())>=60000) setPollEnabled(false);
+ return date;
}
public void setDate(Date date) {
@@ -72,6 +79,7 @@
}
public void setPollEnabled(boolean pollEnabled) {
+ if (pollEnabled) setPollStartTime(null);
this.pollEnabled = pollEnabled;
}
@@ -98,5 +106,13 @@
public void setZip(String zip) {
this.zip = zip;
}
+
+ public Date getPollStartTime() {
+ return pollStartTime;
+ }
+
+ public void setPollStartTime(Date pollStartTime) {
+ this.pollStartTime = pollStartTime;
+ }
}
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/poll/examples/clock.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/poll/examples/clock.xhtml 2007-10-16
09:55:27 UTC (rev 3391)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/poll/examples/clock.xhtml 2007-10-16
10:02:47 UTC (rev 3392)
@@ -2,25 +2,29 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<rich:separator height="1"/>
<a4j:region>
<h:form>
- <a4j:poll id="poll" interval="500"
enabled="#{userBean.pollEnabled}" reRender="serverDate"/>
+ <a4j:poll id="poll" interval="500"
enabled="#{userBean.pollEnabled}" reRender="poll,grid"/>
</h:form>
</a4j:region>
<h:form>
- <h:panelGrid columns="2" width="80%">
- <a4j:commandButton style="width:120px" id="control"
- value="#{userBean.pollEnabled?'Stop':'Start'}
Polling"
- reRender="poll, control">
- <a4j:actionparam name="polling"
value="#{!userBean.pollEnabled}"
- assignTo="#{userBean.pollEnabled}"/>
- </a4j:commandButton>
- <h:outputText id="serverDate" style="font-size:16px"
value="Server Date: #{userBean.date}"/>
- </h:panelGrid>
+ <h:panelGrid columns="2" width="80%" id="grid">
+ <h:panelGrid columns="1">
+ <h:outputText value="Polling Inactive" rendered="#{not
userBean.pollEnabled}"></h:outputText>
+ <h:outputText value="Polling Active"
rendered="#{userBean.pollEnabled}"></h:outputText>
+ <a4j:commandButton style="width:120px" id="control"
+ value="#{userBean.pollEnabled?'Stop':'Start'}
Polling"
+ reRender="poll, grid">
+ <a4j:actionparam name="polling"
value="#{!userBean.pollEnabled}"
+ assignTo="#{userBean.pollEnabled}"/>
+ </a4j:commandButton>
+ </h:panelGrid>
+ <h:outputText id="serverDate" style="font-size:16px"
value="Server Date: #{userBean.date}"/>
+ </h:panelGrid>
</h:form>
<rich:separator height="1" style="padding-top:10px"/>
</ui:composition>
\ No newline at end of file