1 Reply Latest reply on Apr 4, 2007 2:34 PM by Sergey Smirnov

    IgnoreDupResponses and eventQueue attributes

    albert_steed Newbie

      Hello,
      Can anyone please give me practical examples of usage for the following attibutes of a4j:support
      -IgnoreDupResponses
      -eventQueue
      I read the documentation and was not able to figure out any example usage.
      Thanks in advance,
      A.

        • 1. Re: IgnoreDupResponses and eventQueue attributes
          Sergey Smirnov Master

          If you do not use eventsQueue attribute, any ajax request are sent immediately as soon as the triggered client-side event is fired.

          For example, if you have a behavior like in the simple repeater example:

          http://livedemo.exadel.com/a4j-simpleRepeator/

          the request will be sent each time you type the character.

          Those might causes some problems:

          a) requests flood - if you type too false, the several request will be processed simultaneously. As soon as earlier JSF implementations are not designed to work in such stress environment, some glitches might occur

          b) unnecessary server side activity - if you have already typed 5 character quickly, you are not interesting any more to have bean updated 5 times. The previous 4 requires are not actual. You expect to see 5 characters on the screen after ajax response comes back.

          c) unnecessary client side activity - the same as b). Why the page should be refreshed for first, second, third and fourth characters if you already typed five?

          Once you define the eventsQueue attribute, the requests will be put into the queue first. The next requiest will be sent to server only when the response for the previous one comes back.

          So, only one request is processed at the same time for particular queue. You can define the same queue name for different Ajax Command Components are that will be shared the same queue

          eventsQueue is good together with requestDelay attribute. requestDelay defines the timeout is ms that any request will wait before sending

          If you define eventsQueue attribute, Ajax4jsf starts to remove "the similar" previous request from the queue and send only the latest one.

          For example, in the repeater example above: if you have a queue, requestDelay = "500" and types five characters during the 0.5 sec, only one request will be send. The previous one will be removed. However, if you want still to know how many events are fired, this information is available on the server side from AjaxContext object.

          "The similar" means the request that fired by the same event and put to the same queue.

          What if you type 5 characters during 0.5 sec and then type one more after the Ajax request is already sent from this queue. There is no reason to refresh the page for 5 character block if you already expect to see 6 characters later on.
          So, this is what ignoreDupResponses attribute is for. If it set to true, the ajax response will be discarded if the fresh similar request is already in the queue.


          P.S. Vote for "Ajax4jsf. Master Class" articles. This post text will be there along with other interesting tips and tricks.

          http://jboss.com/index.html?module=bb&op=viewtopic&t=105234