9 Replies Latest reply on Mar 26, 2007 1:19 PM by sergeysmirnov

    a4j:commandButton rerender

    maitre

      Is it possible to rerender a a4j:commandButton from another button using ajax request.

      <a4j:commandButton
      rendered="${Bean.moveFirstPossible}"
      id="moveFirst"
      reRender="dataTable,moveFirst,movePrevious"
      actionListener="${Bean.moveFirst}"
      />

      <a4j:commandButton
      rendered="${Bean.movePreviousPossible}"
      id="movePrevious"
      reRender="dataTable,moveFirst,movePrevious"
      actionListener="${Bean.movePrevious}"
      />

      In my actionListener the values of moveFirstPossible and movePreviousPossible change but all button are still visible.
      When I reload the entire page, I got the right result.

        • 1. Re: a4j:commandButton rerender
          ilya_shaikovsky

          what is the scope of your bean?

          • 2. Re: a4j:commandButton rerender
            maitre

            They are session bean

            • 3. Re: a4j:commandButton rerender
              ilya_shaikovsky

              Need some more info.. environment, log etc.. In my case the same

              <a4j:commandButton action="#{bean.disableAction}" value="test" reRender="test"></h:commandButton>
              
              <a4j:outputPanel id="test">
              <h:commandButton value="hide Mee" rendered="#{bean.property1}"></h:commandButton>
              <a4j:outputPanel>
              
              

              works as you expect.


              • 4. Re: a4j:commandButton rerender
                maitre


                When you use action #{bean.disableAction} you reload all the page. That whay i am using actionListener.

                I want to use Ajax to reload the status of my button.
                Why do you disable a panel not the commandButton in your example

                • 5. Re: a4j:commandButton rerender
                  ilya_shaikovsky

                  1) action and actionListener both doesn't reloads the whole page in Ajax action components

                  2) after button - isn't rendered it can't be found in tree to be correctly updated. so update some actual wrapper and all will works as you need.

                  • 6. Re: a4j:commandButton rerender
                    maitre

                    what do you put in bean.disableAction ?

                    my method look like this

                    public void movePrevious(actionevent event)
                    {
                    this->moveFirst = true;
                    }

                    public boolean moveFirst()
                    {
                    return this-»moveFirst;
                    }

                    so i whant my button to be rendered with the new value of "moveFirst"

                    • 7. Re: a4j:commandButton rerender
                      ilya_shaikovsky

                       

                      public String disableAction() {
                       setProperty1(!isProperty1());
                       return null;
                      }
                      

                      This is my code

                      • 8. Re: a4j:commandButton rerender
                        maitre


                        Finaly it is working :)

                        I am re-rendering the outputPanel that contain the button and it work.
                        Thank you very nuch ilya_shaikovsky.

                        I am still wondering why I can re-render directly the button.

                        • 9. Re: a4j:commandButton rerender

                          the key point is a 'rendered' attribute, but not the commandButton or any other component.

                          If rendered attribute is false, the component is in the component tree of the server, but has no representation in the browser DOM tree. I.e. there is no DOM node with id on the component.
                          When you point to such component with reRender attribute, it is rendered (if 'rendered' becomes true) and even sent to the client. However, there is nothing to replace on the client (no placeholder as I said above).
                          So, if the component has 'rendered' attribute always point to one of the parent with reRender