richfacesjsf-1.2seam2

JSF1.2 - richFaces progressBar - the simple demo is not working


I'm trying to use the simple demo from the richfaces progressBar page.

When i go to the page, it's rendering the start button, after pressing the button the progressbar is showing up, showing 0% - and instead of counting until 100 is shows -1 and that's it - no counting, nothing.
So this means, that the startTime is null - but normally it should have the time the button was pressed.

I also tried it with @AutoCreate and also with @Out over the 3 variables... It's not really working well..

System is working on JSF 1.2 and Seam.

The xhtml looks like this:

<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>
    <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>

The bean looks like this:

/**
* 
*/
package org.richfaces.demo.progressBar;

import java.util.Date;

/**
* @author Ilya Shaikovsky
*
*/
@Name("progressBarBean")
public class ProgressBarBean {

private boolean buttonRendered = true;
private boolean enabled=false;
private Long startTime;

public ProgressBarBean() {
}

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;
}
}

Thank you!


Solution

  • Try to add the @Scope(ScopeType.SESSION) or @Scope(ScopeType.PAGE) to your bean and see if that could work.