2 Replies Latest reply on Jul 3, 2007 8:50 AM by Joe Greene

    preventing duplicate rerendering when using <a4j:poll...>

    Joe Greene Novice

      Is there a way to prevent unnecessary updates on a page when using the "rerender" attribute of the a4j:poll component? The "ignoreDupResponses" sounds like it would work, but its description in the docs makes the attribute name sound misleading. What does it actually do? I'm updating a few components on the page, but I don't want to do a rerender unless something has actually changed.

        • 1. Re: preventing duplicate rerendering when using <a4j:poll...
          Sergey Smirnov Master

          if you define queue name for your Ajax tag, Ajax4jsf will send only latest "similar" Ajax request. "Similar" means the request generated by the same javascript event (like onkeyup, onclick, onmouseout etc).

          For example, You have

          ....
          <h:inputText value="#{bean.text}">
           <a4j:support event="onkeyup" eventsQueue="myqueue"
           requestDelay="1000" reRender="panel" />
          </h:inputText>
          ...
          <h:panelGrid id="panel">
          ...
          </h:panelGrid>
          ...

          If user types "foo" during 1 sec. only one request with "foo" string will be sent (but not three of them with "f", "fo", "foo").

          What if user continues to type while the request is on the way to server and back to client?

          ignoreDupResponses allows to ignore the response with "foo" if user already types "foobar". I.e. the response is ignored if the queue already contains the "similar" request.

          This is like this stuff works.

          As you see, there is nothing about comparing the old content with the new content. This is out of scope for Ajax4jsf.

          If you know the criteria when the content is changed on the level of your application you can manipulate with reRender attribute on the server side.
          I.e. if you say reRender="#{bean.updateList}" you can have getUpdateList() method that returns list of re-rendered components. So, if this list is empty, nothing will be updated on the client side when the Ajax response is done.




          • 2. Re: preventing duplicate rerendering when using <a4j:poll...
            Joe Greene Novice

            Thanks, Sergey -
            Yes, after my first post, I thought of the same thing you suggested at the end of your post. I'll try using the reRender attribute, and have a list of ids to update. In the bean, I'll make the list empty if nothing has changed. sounds exactly like what you suggested. Sounds like it should work.