6 Replies Latest reply on Nov 15, 2011 4:27 PM by Ashis Sahoo

    rich:progressBar issue

    Ashis Sahoo Newbie

      Hello Friends,

      I need a help on richfaces progressBar. It is somehow not calling "out" after completion. It is calling getCurrentValue() in the backing bean infinitely even if maxValue reaches to 100. Here is my code:

       

                    <rich:progressBar id="pb" mode="ajax" value="#{progressBarBean.currentValue}"

                                           label="#{progressBarBean.currentValue} %" interval="1000"

                                           minValue="0" maxValue="100" enabled="#{progressBarBean.enabled}"

                                           ignoreDupResponses="true" render="progressPanel" reRenderAfterComplete="out">

       

                      </rich:progressBar>

       

                     <h:outputText value="completed!!" id="out" /><br/>

       

      Backing bean method:

       

           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(100);

              }

          }

       

       

      Any input would be greatly appreciated. Thanks in advance.

       

      Thanks

      A.

        • 1. Re: rich:progressBar issue
          iabughosh Master

          Hi Sahoo, welcome to the community, when you reach 100 (or your max limit) set progress bar enabled attribute to false.

          • 2. Re: rich:progressBar issue
            Ashis Sahoo Newbie

            Hi Ibrahim - Thanks for your reply. I did change backing bean code to set false if I reach 100 (max limit), but still it is calling getCurrentValue() in the backing bean infinitely. I do not able to figure it out what do I miss.

             

            My updated backing bean method is:

             

            public Long getCurrentValue() {

                    if (isEnabled()) {

                        Long current = (new Date().getTime() - startTime) / 1000;

                        if (current >= 100) {

                           setEnabled(false);    //setting false once i hit the mix limit

                           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(100);

                    }

                }

             

            I would appreciate any input.

             

            Thanks

            A.

            • 3. Re: rich:progressBar issue
              iabughosh Master

              is your bean scope (request), if yes try changing it to View or Session scope.

              • 4. Re: rich:progressBar issue
                Ashis Sahoo Newbie

                Hi Ibrahim- Thanks for your reply. My bean scope is session scope already.

                • 5. Re: rich:progressBar issue
                  iabughosh Master

                  please attach your bean & .xhtml source.

                  • 6. Re: rich:progressBar issue
                    Ashis Sahoo Newbie

                    Hi Ibrahim- I solved the problem. The problem was render="progressPanel", I was refreshing the same panel where the progress bar was there. It was causing infinite loop. So the final tag should:

                     

                    <rich:progressBar id="pb" mode="ajax" value="#{progressBarBean.currentValue}"

                                                         label="#{progressBarBean.currentValue} %" interval="1000"

                                                         minValue="0" maxValue="100" enabled="#{progressBarBean.enabled}"

                                                         ignoreDupResponses="true" reRenderAfterComplete="out">

                     

                                    </rich:progressBar>

                     

                    Thanks for your reply.

                     

                    Ashis