3 Replies Latest reply on Mar 5, 2010 7:32 AM by Ilya Shaikovsky

    fire clicking on a4j:commandbutton

    Sascha Janz Master

      i got a page with a4j:commandbuttons.

       

      i want to avoid, if a user clicks a button multiple times, the server function is executed more than once.

       

      i thought a4j:queue will do that for me with ignoreDupResponses=false

       

      but the server function is executed minimum twice.

       

      where is my mistake?

        • 1. Re: fire clicking on a4j:commandbutton
          Nick Belaevski Master

          Hi Sascha,

           

          ignoreDupResponses is a client-side optimization feature, it cannot prevent calling server methods. You can disable a4j:commandButton on click and make it enabled in oncomplete.

          • 2. Re: fire clicking on a4j:commandbutton
            Harut Sargsyan Apprentice

            Hi,

             

                 You can show some "loading" message when the button clicked till it's action will complete.

            E.g.

             

            <a4j:commandButton id="cleanButton"
                              value="#{bundle['mytask.search.clean']}" 
                              actionListener="#{searchTaskController.onCleanSearchRequested}"
                              reRender="searchPart"                 
                              onclick="Richfaces.showModalPanel('ajaxLoadingBarId')"
                              oncomplete="Richfaces.hideModalPanel('ajaxLoadingBarId')"
            />

             

            Where modalPanel is:

             

            <rich:modalPanel id="ajaxLoadingBarId"
                                             autosized="false"
                                             resizeable="false"
                                             width="200"
                                             height="50"
                                             style="border:#000000; border-width:0px; border-style:hidden; background:transparent;"
                                             shadowDepth="-500000"
                                             showWhenRendered="false">
                              
                                    <h:graphicImage value="/loading.gif" alt="loading"/>                  
            </rich:modalPanel>

             

            Use any "Loading image" in the above modalPanel.

            You can add mentioned 2 javascript rows in any rich/a4j component which sends ajax request.

            onclick="Richfaces.showModalPanel('ajaxLoadingBarId')"
            oncomplete="Richfaces.hideModalPanel('ajaxLoadingBarId')"

             

            In case of <a4j:support/> use onsubmit insteadof onclick...

             

            Regards, Harut.

            • 3. Re: fire clicking on a4j:commandbutton
              Ilya Shaikovsky Master
              or just disable the button on onclick and enable on oncomplete.