4 Replies Latest reply on Jan 13, 2009 4:06 PM by dietice

    Progressbar not displayed

    toomtooms

      Hi,

      I've got a problem when using progressbar component. The progress bar is only displayed when the max value is reached. I want the progress bar to be displayed when I click on the a4j:commandButton and see the value increase.

      Here is my jsp :

      <a4j:commandButton actionListener="#{transfertDocsBackingBean.doTransfert}"
       value="Transférer"/>
      
       <rich:progressBar id="progressBar" value="#{transfertDocsBackingBean.nbDocsProcessed}"
       interval="2000" label="#{transfertDocsBackingBean.nbDocsProcessed}"
       enabled="true" minValue="0" maxValue="#{transfertDocsBackingBean.nbDocsToMove}">
       </rich:progressBar>



      and my backing bean :
      public class TransfertDocsBackingBean {
      ...
       public int getNbDocsProcessed() {
       return nbDocsProcessed;
       }
      ...
       public void doTransfert(ActionEvent event) {
      ...
       nbDocsToProcess = 100;
       for(int i = 0; i < nbDocsToProcess; i++) {
       Thread.sleep(500);
      
       this.nbDocsProcessed = i+1;
       }
      ...
      }


        • 1. Re: Progressbar not displayed
          ilya_shaikovsky

          works just as you designed. Because in your case the request takes all the processing of long running operation inside itself. So after response comes - progress not needed anymore.
          request which should activate progress should run the process in separate thread for example.

          • 2. Re: Progressbar not displayed

            ilya_shaikovsky, You are correct. It works as designed. But how do you make the progress bar work in a method that takes a long time?

            The progress bar waits for the method to return! Once the method returns processing is already completed - then you don't see a progress bar.

            Does anyone know how to get this example to work?

            J.

            • 3. Re: Progressbar not displayed
              ilya_shaikovsky

              Just run new thread in your method which will perform this operation. Your long running operation should not keeps the request, which was sent to start the operation, all the time. Something like defined in our richfaces demo push example but adopted to your case.

              • 4. Re: Progressbar not displayed

                The solution to the problem was to have the servlet, or backing bean, issue an asynchronous request to the EJB layer via MQ (this is a std pattern). Hence the web request does not wait for the EJB layer to finish processing.

                Hope this helps.