JBoss.orgCommunity Documentation
The <a4j:queue> component creates queues of requests of Ajax request. With the help of this component other Ajax4JSF or RichFaces components can reference and use it.
By means of the attributes of this component you can manage server requests of the components, which refered to it.
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 | JavaScript code for call after the request has removed from the queue |
onrequestqueue | JavaScript code for call after the request has got into the queue |
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 | ID (in format of call UIComponent.findComponent()) of Request status component |
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 |
There is possibility of the creation as a named queue so and a queue with the default name. You can reference the named queue only from such components which have "eventsQueue" attribute.
So, the following example helps to create the named queue.
Example:
<a4j:queue name="myQueue" ... />
...
<h:inputText value="#{myQueue.text}">
<a:support id="onblur" event="onblur" eventsQueue="myQueue"/>
</h:inputText>
...>
See the example of the creation the default queue below.
Example:
<h:form>
...
<a4j:queue/>
...
</h:form>
Example:
import org.ajax4jsf.component.html.HtmlQueue;
...
HtmlQueue myQueue = new HtmlQueue();
It's possible by means of the <a4j:queue> component to create the several types of the queues. The information about it you can find here.
In order to disable or enable the <a4j:queue> component on the page you can use the "disabled" attribute.
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 example of the usage this attribute you can find below.
Example:
...
<a4j:queue sizeExceededBehavior="dropNext" requestDelay="5000" ... />
...
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.
You can define the JavaScript code for call after Ajax response receiving and before updating DOM on a client side via the "onbeforedomupdate" attribute.
The "onrequestqueue" attribute is a JavaScript code for call which fired after the new request has been added to queue. And the "onrequestdequeue" attribute is the code for call which fired after the request has been removed from queue.
The "onsubmit" attribute is fired after request is completed. This attribute allows to invoke JavaScript code before an Ajax request is sent.
The additional information about the "requestDelay" , "timeout" and "ignoreDupResponses" you can find in this section.
Here you can see the example of <a4j:queue> usage and sources for the given example.