livedemo progressBar code does not work
asookazian Jun 25, 2009 12:23 PMSeam 2.0.2-FP
RF 3.3.1.GA
The code (xhtml and JavaBean) in the livedemo:
http://livedemo.exadel.com/richfaces-demo/richfaces/progressBar.jsf?c=progressBar&tab=usage
does not work. I see 0% and then -1% when I click the button. The bar remains white with a blue border the entire time. Why and how to fix?
.xhtml:
<!DOCTYPE composition 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:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
template="/templates/normal.xhtml">
<ui:define name="body">
<h:form>
<a4j:outputPanel id="progressPanel">
<rich:progressBar value="#{progressBarBean.currentValue}"
interval="2000" label="#{progressBarBean.currentValue} %"
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" reRender="progressPanel"
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" reRender="progressPanel"
rendered="#{progressBarBean.buttonRendered}"
style="margin: 9px 0px 5px;" />
</f:facet>
</rich:progressBar>
</a4j:outputPanel>
</h:form>
</ui:define>
</ui:composition>JavaBean:
package com.cox.ers.session;
import java.util.Date;
import org.jboss.seam.annotations.Name;
@Name("progressBarBean")
public class TestProgressBarBean {
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;
}
}