Send your remarks, comments or wishes to doc team
Subject:
Message:
Your name:
Your email:

JBoss.org Community Documentation

- Prev
- Next

## 6.20. < a4j:queue >

### 6.20.1. Description

The <a4j:queue> component creates queues of requests of Ajax request that other Ajax4JSF or RichFaces components can reference and use.

This component can manage server requests of the components, which referred to it, with help of its attributes.

Table 6.39. a4j : queue attributes

Attribute Name | Description
--- | ---
binding | The attribute takes a value-binding expression for a component property of a backing bean
disabled | If "true", disables this component on page.
id | Every component may have a unique id that is automatically created if omitted
ignoreDupResponses | Attribute allows you to ignore an Ajax response produced by a request if the newest 'similar' request is in the queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows avoiding unnecessary updates on the client side if the response isn't actual now
name | The name of the queue
onbeforedomupdate | JavaScript code for call before DOM has been updated on client side
oncomplete | JavaScript code for call after request completed on client side
onerror | HTML: a script expression; event fires whenever an JavaScript server side error occurs
onrequestdequeue | onrequestdequeue
onrequestqueue | onrequestqueue
onsizeexceeded | A script expression; a size is exceed
onsubmit | JavaScript code for call before submission of an ajax request
requestDelay | Attribute defines the time (in ms) the request will be waiting in the queue before it is ready to be sent.
size | Defines the number of requests allowed in the queue at one time.
sizeExceededBehavior | Defines the strategies of the queue's behavior if the number of the requests waiting in the queue is exceeded. There are four strategies: dropNext (by default), dropNew, fireNext , fireNew.
status | status
timeout | Waiting time for response on a particular request. If no response is received during this time, the request is aborted

Table 6.40. Component identification parameters

Name | Value
--- | ---
component-family | org.ajax4jsf.Queue
component-class | org.ajax4jsf.component.html.HtmlQueue
renderer-type | org.ajax4jsf.QueueRenderer
tag-class | org.ajax4jsf.taglib.html.jsp.QueueTag

### 6.20.2. Creating on a page

In order to create the named queue, see following example.

Example:

    <a4j:queue name="myQueue" ... />

    ...

    <h:inputText value="#{myQueue.text}">

        <a:support id="onblur" event="onblur" eventsQueue="myQueue"/>

    </h:inputText>

    ...

    <a4j:commandButton eventsQueue="myQueue" ... >

You can also create the queue with a default name. This queue is global for the all form. See the example below.

Example:

    <h:form>

                ...

           <a4j:queue/>

           ...

    </h:form>

### 6.20.3. Creating the Component Dynamically Using Java

Example:

    import org.ajax4jsf.component.html.HtmlQueue;

    ...

    HtmlQueue myQueue = new HtmlQueue();

### 6.20.4. Key attributes and ways of usage

By means of the <a4j:queue> component you can create several types of queues associated with it.

- In order to create global queue for the all Can set a queue globally in "web.xml". You don't need set the queue on the page itself. The global queue can be used by all components. You can see the example below:

      <context-param>

         <param-name>org.richfaces.queue.global.enabled</param-name>

         <param-value>true</param-value>

         </context-param>

  In order to enable/disable a global queue for concrete views see the following examples:

      <a4j:queue name="org.richfaces.global_queue" disabled="false"... />

  In order to disable the queue the "disabled" attribute should be "true".

- You can create a separate queue for a specific form with the help of the <a4j:form> or <h:form> tags. It is the queue only for this form. The queue's name don't define by default if you haven't defined it.

  Example:

      <h:form ... >

          ...

          <a4j:queue ... />

          ...

          </h:form>

  or:

  Example:

      <a4j:form ... >

          ...

          <a4j:queue name="myQueue" ... />

          ...

      </a4j:form>

  If you use the <a4j:form> tag, you can reference a named queue as the form's default.

  Example:

      <a4j:form eventsQueue="myQueue" ...>

         ...

         </a4j:form>

- With the help of the "eventsQueue" attribute you can reference a named queue from any a4j or rich component that supports this attribute.

  Example:

      <a4j:queue name="myQueue" ... />

      ...

      <h:inputText value="#{queueBean.text}">

          <a4j:support id="onblur" event="onblur" eventsQueue="myQueue"/>

      </h:inputText>

      <a4j:commandButton eventsQueue="myQueue" ... >

  As a result all requests generated after the "onblur" event of the <h:inputText> component, and clicking of the <h:commandButton> will be funneled through the `"myQueue"`.

  If you try to refer to the nonexistent queue the new named queue will be created with all default settings.

The "size" attribute helps you to set the number of requests allowed in the queue at one time.

The "sizeExceededBehavior" attribute defines four strategies of the queue's behavior if the number of the requests waiting in the queue is exceeded:

- dropNext - drops next request that should be fired

- dropNew - drops the incoming request

- fireNext - immediately fires the next request in line to be fired

- fireNew - immediately fires the incoming request.

The "requestDelay" attribute defines delay time for all the requests which fired using this queue.

Example:

    <a4j:queue requestDelay="2000" ... />

As a result all the requests are fired with to 2 sec delay.

The requests collected in the queue, combining similar ones, during request delay. Note, that such requests can combine, if they are raised sequentially, in order to not block the queue and not to change the requests order.

### 6.20.5. Relevant resources links

Here you can see the example of <a4j:queue> usage and sources for the given example.

- Prev6.19. < a4j:push >
- Top of page
- Front page
- Next6.21. < a4j:region >