Author: ilya_shaikovsky
Date: 2008-03-03 11:37:36 -0500 (Mon, 03 Mar 2008)
New Revision: 6499
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/progressBar/examples/
trunk/samples/richfaces-demo/src/main/webapp/richfaces/progressBar/examples/client.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/progressBar/examples/polling.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/progressBar/usage.xhtml
Log:
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java 2008-03-03
16:37:36 UTC (rev 6499)
@@ -0,0 +1,55 @@
+/**
+ *
+ */
+package org.richfaces.demo.progressBar;
+
+import java.util.Date;
+
+/**
+ * @author Ilya Shaikovsky
+ *
+ */
+public class ProgressBarBean {
+
+ private boolean enabled=false;
+ private Long startTime;
+
+ public ProgressBarBean() {
+ }
+
+ public String startProcess() {
+ setEnabled(true);
+ setStartTime(new Date().getTime());
+ return null;
+ }
+
+ public Long getCurrentValue(){
+ if (isEnabled()){
+ Long current = (new Date().getTime() - startTime)/1000;
+ if (current>100){
+ setEnabled(false);
+ }else if (current.equals(0)){
+ System.out.println("called");
+ return new Long(1);
+ }
+ return (new Date().getTime() - startTime)/1000;
+ }else
+ return Long.valueOf(-1);
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Long getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(Long startTime) {
+ this.startTime = startTime;
+ }
+}
Added:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/progressBar/examples/client.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/progressBar/examples/client.xhtml
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/progressBar/examples/client.xhtml 2008-03-03
16:37:36 UTC (rev 6499)
@@ -0,0 +1,37 @@
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
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:rich="http://richfaces.org/rich">
+
+ <script>
+//<![CDATA[
+ var counter = 1;
+ var intervalID;
+ function updateProgress(i) {
+ $('form:progressBar').component.setValue(counter*5);
+ if ((counter++)>20)
+ clearInterval(intervalID);
+ }
+
+ function startProgress(){
+ counter=1;
+ $('form:progressBar').component.enable();
+ $('form:progressBar').component.setValue(1);
+ intervalID = setInterval(updateProgress,5000);
+ }
+//]]>
+ </script>
+ <h:form id="form">
+ <rich:progressBar mode="client" id="progressBar">
+ <f:facet name="initial">
+ <h:outputText value="Process doesn't started yet"/>
+ </f:facet>
+ <f:facet name="complete">
+ <h:outputText value="Process Done"/>
+ </f:facet>
+ </rich:progressBar>
+ <button type="button" onclick="startProgress();">Start
Progress</button>
+ </h:form>
+</ui:composition>
\ No newline at end of file
Added:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/progressBar/examples/polling.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/progressBar/examples/polling.xhtml
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/progressBar/examples/polling.xhtml 2008-03-03
16:37:36 UTC (rev 6499)
@@ -0,0 +1,24 @@
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
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:rich="http://richfaces.org/rich">
+
+ <h:form>
+ <h:outputText
value="http://jira.jboss.com/jira/browse/RF-2364"/>
+ <a4j:outputPanel id="progressPanel">
+ <a4j:commandButton action="#{progressBarBean.startProcess}"
value="startProcess" reRender="progressPanel" rendered="#{not
progressBarBean.enabled}"/>
+
+ <rich:progressBar value="#{progressBarBean.currentValue}"
interval="2000"
+ label="#{progressBarBean.currentValue} %"
enabled="#{progressBarBean.enabled}">
+ <f:facet name="initial">
+ <h:outputText value="Process doesn't started yet"/>
+ </f:facet>
+ <f:facet name="complete">
+ <h:outputText value="Process Done"/>
+ </f:facet>
+ </rich:progressBar>
+ </a4j:outputPanel>
+ </h:form>
+</ui:composition>
\ No newline at end of file
Added: trunk/samples/richfaces-demo/src/main/webapp/richfaces/progressBar/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/progressBar/usage.xhtml
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/progressBar/usage.xhtml 2008-03-03
16:37:36 UTC (rev 6499)
@@ -0,0 +1,43 @@
+<!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:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:rich="http://richfaces.org/rich">
+ <ui:composition template="/templates/component-sample.xhtml">
+ <ui:define name="sample">
+
+ <p>
+ SHORT DESCRIPTION
+ </p>
+
+ <p>
+ Server Side
+ </p>
+
+ <div class="sample-container" >
+
+ <ui:include src="/richfaces/progressBar/examples/polling.xhtml"/>
+ <ui:include src="/templates/include/sourceview.xhtml">
+ <ui:param name="sourcepath"
value="/richfaces/progressBar/examples/polling.xhtml"/>
+ </ui:include>
+ </div>
+
+ <p>
+ Client Side
+ </p>
+
+ <div class="sample-container" >
+
+ <ui:include src="/richfaces/progressBar/examples/client.xhtml"/>
+ <ui:include src="/templates/include/sourceview.xhtml">
+ <ui:param name="sourcepath"
value="/richfaces/progressBar/examples/client.xhtml"/>
+ </ui:include>
+ </div>
+
+
+ </ui:define>
+
+
+ </ui:composition>
+</html>