3 Replies Latest reply on Apr 9, 2009 10:20 AM by Ilya Shaikovsky

    reRender after ajax request completes.

    Peter D Newbie

      I'm sorry if this has been asked before but I can't seem to find a solid answer on the forum. I have a dataTable that needs to be refreshed after a "vote" is made for a specific item.

      A user will press a "+" or "-" on each row will which update a database entry and a number will be updated and the table needs to be sorted based on this number.

      Everything is working fine except it seems like the table rerenders too quickly and doesn't pickup the database update. If I refresh manually (F5) the changes then appear.

      So my question is: Is there a way to rerender on an "oncomplete"?

      Here is the JSF for my "+" button:

      <a4j:commandButton value="+" action="#{home.addvote(resto.id)}" rendered="#{identity.loggedIn}"
      onclick="this.disabled=true" oncomplete="this.disabled=false" />


      if I add reRender="restoTable" (my datatable) it gives me the problem of rendering too fast.

      Thanks for you help.

        • 1. Re: reRender after ajax request completes.
          Ilya Shaikovsky Master

          reRendering takes place after request completed and response from server returned. So we can't say about db calls "after" the reRendering happens even in theory.

          show your code please.

          • 2. Re: reRender after ajax request completes.
            Peter D Newbie

            Thank you for your response. And I admit after some testing you are correct. It seems the table doesn't rerender (visually) when there is sorting enabled on any column on the datatable.

            If I leave all columns unsorted then the table updates correctly. If I have any column sorted then it seems like the data in the back gets updated but nothing on the table changes visually. I say "the data in the back" because if I vote for an item and it becomes the top voted for item, the table won't refresh visually, therefor if I press the "+" next to that item again I am no longer voting for the same item.

            I know this is correct because the votes to not get correctly counted when pressing the corresponding "+" or "-" when sorted. (The wrong item gets voted).

            So I guess my new question is: Is there anyway to get the sorting to update visually after a rerender?

            • 3. Re: reRender after ajax request completes.
              Ilya Shaikovsky Master

              sorry but please show you snippet and your RF version(it's highly recommended to use latest 3.3.0 GA or even 3.3.1 Beta)