6 Replies Latest reply on Aug 9, 2009 6:10 AM by nbelaevski

    Can I control the order of attributes in a4j:commandButton?

      Here is the commanButton:

      <a4j:commandButton type="submit" value="SUBMIT PROJECT CHANGES" action="#{updateAllBean.updateProject}"
       actionListener="#{treeBean.reloadTree}" reRender="tree" />


      I need the actionListener to happen first, and then the reRender, but it seems that it is happening in the reverse order, reRender first, actionListener second.

      The action attribute edits the data stored on a web service. I have a rich:tree on this page to represent the data on this web service. So when you hit this submit button, I need that rich:tree to be reRendered with the newly submited data. Right now though, if I hit this submit button with the changes, it does change the data on the web service, but it reRenders the tree before the actionListener has a chance to happen.
      I know this because if I hit the submit button once, it does this, and then if I hit that submit button a second time, it does reRender the tree with the new data. So the actionListener code is correct, and reloads the tree List just fine, but I need the reRender to wait until after this happens before reRendering the tree.

      Or if there is a better way to handle this faster please let me know, because the actionListener event takes 3-5 seconds to complete so its a bit slow.

        • 1. Re: Can I control the order of attributes in a4j:commandButt

          When someone hits this submit button, I need my rich:tree to be reRendered with the new values. The actionListener does reload the tree with values, but it is not reflected on the page for some reason, unless I hit the submit button a second time.

          Is there anything else I can do? What can I do to make my rich:tree reload with values and show those new values on my page as soon as the submit button is pressed?

          Or is there something I can do to monitor the tree List, and if the values in that List change it automatically reloads the rich:tree with the new values?

          There has to be some way to do this, the devs had to have made a way to do this, it seems like a basic need.

          • 2. Re: Can I control the order of attributes in a4j:commandButt
            nbelaevski

            Hi,

            First action event fires and all listeners are notified, then re-rendering occurs. You can't reverse this order anyhow either as you can't reorder JSF phases.

            • 3. Re: Can I control the order of attributes in a4j:commandButt

              Thats what I thought, it seemed like the logical order.
              But does this mean that it notifies the listeners, and then reRenders before the listener methods have completed? This seems like what is happening. My listener method begins to run, but this method takes 3-6 seconds to complete.

              Is there any way I can tell the reRender to wait until the actionListener is totally complete before it ReRenders the page?

              • 4. Re: Can I control the order of attributes in a4j:commandButt
                nbelaevski

                You are not right. Execution of all listeners is complete before re-rendering occurs.

                • 5. Re: Can I control the order of attributes in a4j:commandButt

                  So if my actionListener calls a method that reloads my List with the new projects, this method will complete first, and then the tree will get reRendered right?

                  This is exactly how I have it set up though, but for some reason, the method gets called and completely loads the list with new project values, and then the tree is reRendered because I see it briefly disappear and re appear. But for some reason it is still using the values from the old projectList and not the values that were just loaded in by the method called by the actionListener.

                  Any idea why this may be happening?

                  • 6. Re: Can I control the order of attributes in a4j:commandButt
                    nbelaevski

                    Are requests happening in parallel? Do you start some king of asynchronous processing from your action method?