Author: amarkhel
Date: 2010-10-01 09:52:44 -0400 (Fri, 01 Oct 2010)
New Revision: 19404
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/progressBar/
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/ajaxProgressBar.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/clientProgressBar.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/ajaxProgressBar-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/clientProgressBar-sample.xhtml
Modified:
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
Log:
Add sample for progressBar
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java 2010-10-01
13:52:44 UTC (rev 19404)
@@ -0,0 +1,71 @@
+/**
+ *
+ */
+package org.richfaces.demo.progressBar;
+
+import java.util.Date;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ViewScoped;
+
+/**
+ * @author Ilya Shaikovsky
+ *
+ */
+@ManagedBean
+@ViewScoped
+public class ProgressBarBean {
+
+ private boolean buttonRendered = true;
+ private boolean enabled=false;
+ private Long startTime;
+
+ public String startProcess() {
+ setEnabled(true);
+ setButtonRendered(false);
+ setStartTime(new Date().getTime());
+ return null;
+ }
+
+ public Long getCurrentValue(){
+ if (isEnabled()) {
+ Long current = (new Date().getTime() - startTime)/1000;
+ if (current>100){
+ setButtonRendered(true);
+ } else if (current.equals(0)) {
+ return new Long(1);
+ }
+ return (new Date().getTime() - startTime)/1000;
+ }
+ if (startTime == null) {
+ return Long.valueOf(-1);
+ } else {
+ return Long.valueOf(101);
+ }
+
+ }
+
+ 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;
+ }
+
+ public boolean isButtonRendered() {
+ return buttonRendered;
+ }
+
+ public void setButtonRendered(boolean buttonRendered) {
+ this.buttonRendered = buttonRendered;
+ }
+}
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 2010-10-01
13:46:56 UTC (rev 19403)
+++
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-10-01
13:52:44 UTC (rev 19404)
@@ -341,6 +341,20 @@
</sample>
</samples>
</demo>
+ <demo>
+ <id>progressBar</id>
+ <name>rich:progressBar</name>
+ <samples>
+ <sample>
+ <id>ajaxProgressBar</id>
+ <name>ProgressBar in ajax mode</name>
+ </sample>
+ <sample>
+ <id>clientProgressBar</id>
+ <name>ProgressBar in client mode</name>
+ </sample>
+ </samples>
+ </demo>
</demos>
</group>
<group new="true">
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/ajaxProgressBar.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/ajaxProgressBar.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/ajaxProgressBar.xhtml 2010-10-01
13:52:44 UTC (rev 19404)
@@ -0,0 +1,25 @@
+<!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>ProgressBar worked in "ajax" mode </p>
+ <br/>
+ <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/progressBar/ProgressBarBean.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View Bean Source" />
+ <ui:param name="hideLabel" value="Hide Bean Source" />
+ </ui:include>
+</ui:composition>
+
+</html>
\ No newline at end of file
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/clientProgressBar.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/clientProgressBar.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/clientProgressBar.xhtml 2010-10-01
13:52:44 UTC (rev 19404)
@@ -0,0 +1,22 @@
+<!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>ProgressBar worked in "client" mode </p>
+ <br/>
+
+ <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/progressBar/samples/ajaxProgressBar-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/ajaxProgressBar-sample.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/ajaxProgressBar-sample.xhtml 2010-10-01
13:52:44 UTC (rev 19404)
@@ -0,0 +1,32 @@
+<!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">
+ <h:form id="form">
+ <rich:progressBar mode="ajax"
value="#{progressBarBean.currentValue}"
+ interval="2000"
+ enabled="#{progressBarBean.enabled}" minValue="-1"
maxValue="100"
+ reRenderAfterComplete="progressPanel">
+ <f:facet name="initial">
+ <br />
+ <h:outputText value="Process doesn't started yet"
/>
+ <a4j:commandButton
action="#{progressBarBean.startProcess}"
+ value="Start Process" execute="@form"
+ rendered="#{progressBarBean.buttonRendered}"
+ style="margin: 9px 0px 5px;" />
+ </f:facet>
+ <f:facet name="complete">
+ <br />
+ <h:outputText value="Process Done" />
+ <a4j:commandButton
action="#{progressBarBean.startProcess}"
+ value="Restart Process" execute="@form"
+ rendered="#{progressBarBean.buttonRendered}"
+ style="margin: 9px 0px 5px;" />
+ </f:facet>
+ <h:outputText value="#{progressBarBean.currentValue} %"/>
+ </rich:progressBar>
+ </h:form>
+</ui:composition>
\ No newline at end of file
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/clientProgressBar-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/clientProgressBar-sample.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/clientProgressBar-sample.xhtml 2010-10-01
13:52:44 UTC (rev 19404)
@@ -0,0 +1,40 @@
+<!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">
+ <script>
+//<![CDATA[
+ var counter = 1;
+ var intervalID;
+ function updateProgress(i) {
+ RichFaces.$('form2:progressBar').setValue(counter*5);
+ if ((counter++)>20){
+ clearInterval(intervalID);
+ document.getElementById('button').disabled=false;
+ }
+ }
+
+ function startProgress(){
+ counter=1;
+ document.getElementById('button').disabled=true;
+ RichFaces.$('form2:progressBar').enable();
+ RichFaces.$('form2:progressBar').setValue(1);
+ intervalID = setInterval(updateProgress,5000);
+ }
+//]]>
+ </script>
+ <h:form id="form2">
+ <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();"
style="margin: 9px 0px 5px;" id="button">Start
Progress</button>
+ </h:form>
+</ui:composition>
\ No newline at end of file