users@woodstock.java.net

determinate progressBar refresh question

From: Vanessa Black <Vanessa.Black_at_Sun.COM>
Date: Tue, 18 Mar 2008 13:08:26 -0600

Hi folks,

I have a question about implementing the determinate progress bar (I'm using WS 4.1.1). I notice that with my bean in request scope it  gets reinitialized at every progressBar refresh. I looked at the progressBar example on the examples page that you host and I see that in the example, the bean's progress field gets incremented. I don't see how the updates to the progress field stick if the bean is getting initialized at every refresh. Could you clarify this for me?

This error in firebug on every refresh of the progressBar

I has no properties
init(Object id=form1:bar1 event=progress)com_sun_faces_aja... (line 1)
emptyFunction()prototype.js (line 8)
emptyFunction(4)prototype.js (line 8)
emptyFunction()prototype.js (line 8)
emptyFunction()prototype.js (line 8)
var __existingDynaFaces__=null;if(typeof DynaFaces!="undefined"){__existingDynaF...


Here is my example that I was trying this out on:


  <webuijsf:form id="form1">
                        <webuijsf:markup id="leftmargin" tag="div" style="margin:2%">
                            This is a progress bar
                            <br/> <br/>
                            <webuijsf:progressBar id="bar1" type="DETERMINATE"
                            progress="#{determinateProgressBarBean.progress}"
                            refreshRate="3000">
                            </webuijsf:progressBar>
                            <br/> <br/>         
                        </webuijsf:markup>
                    </webuijsf:form>



Here is the bean in request scope



package sandbox.progressbar;

/**
 *
 * This bean backs the JSP implementing a determinate progress bar
 */
public class DeterminateProgressBarBean {

    private int progress = 0;
   
    public DeterminateProgressBarBean() {
        initState();
    }
   
    /**
     * This initializes the state of the bean
     */
    void initState() {
        System.out.println("Initing state");
    }

    /**
     * This updates the progress by 20% every time it is called
     * @return
     */
    public int getProgress() {
        if (progress < 100) {
            progress += 20;
            if (progress > 100) {
                progress = 100;
            }
        }
        return progress;
    }

   
}


Thanks,

Vanessa