Chapter 9. Processing management
This chapter covers those components that manage the processing of information, requests, and updates.
9.1. <a4j:queue>
The
<a4j:queue> component manages the JSF queue of Ajax requests. It provides additional options for a finer control of request processing.
9.1.1. Basic usage
The
<a4j:queue> component works in the same basic way as the standard JSF queue. It can be enabled and disabled through the enabled attribute.
Note
The
<a4j:queue> component does not handle standard JSF requests or requests from component libraries other than RichFaces.
9.1.2. Delaying requests
Use the
requestDelay attribute to add a delay between each request in the queue. Set the requestDelay attribute to the number of milliseconds to wait in between each request. Delaying requests avoids unnecessary processing for actions that would otherwise cause multiple requests, such as typing. Similar requests in the queue are combined while waiting for the request delay.
Example 9.1. Delaying requests
<a4j:queue requestDelay="1500"/>
The queue delays each request by 1500 milliseconds.
9.1.3. Duplicate responses
The client side can update unnecessarily if duplicate responses require similar updates. Set
ignoreDupResponses="true" to ignore duplicate responses. With this setting, the client will not update from a request if a similar request is in the queue.
9.1.4. Queue scopes
Define the queue scope to make it the default queue for all requests in that scope. The scope depends on the placement of the queue and any naming identifiers.
- An unnamed
<a4j:queue>component placed outside any forms becomes the default queue for all requests on the page. - An unnamed
<a4j:queue>component placed inside a form becomes the default queue for all requests within that form. - Use the
nameidentifier attribute to name an<a4j:queue>component. Named queues can be accessed with the<a4j:attachQueue>behavior to act as a queue for specific components and behaviors. Refer to Section 9.1.7, “<a4j:attachQueue>” for details.
Example 9.2. Queue scopes
<a4j:queue name="viewQueue" requestDelay="2000"/> <h:form> <a4j:queue name="formQueue" requestDelay="1500"/> ... </h:form>
The queue outside the form is scoped to the view. The queue inside the form is scoped only to that form.
9.1.5. <a4j:queue> client-side events
The
<a4j:queue> component features several events relating to queuing actions in addition to the common JSF events:
- The
completeevent is fired after a request is completed. The request object is passed as a parameter to the event handler, so the queue is accessible usingrequest.queueand the element which was the source of the request is accessible usingthis. - The
requestqueueevent is fired after a new request has been added to the queue. - The
requestdequeueevent is fired after a request has been removed from the queue.
9.1.6. Reference data
component-type:org.richfaces.Queuecomponent-class:org.richfaces.component.UIQueuecomponent-family:org.richfaces.Queuerenderer-type:org.richfaces.QueueRenderer
9.1.7. <a4j:attachQueue>
The
<a4j:attachQueue> behavior is used together with a <a4j:queue> component to further customize queuing for particular components and behaviors. The <a4j:attachQueue> behavior can override the scope-wide queue settings for an individual component, or attach specific requests to a queue.
9.1.7.1. Overriding scope settings
Queues can be scoped to various levels as described in Section 9.1.4, “Queue scopes”. Use an
<a4j:attachQueue> behavior in the same scope as a queue to override the queue settings for a particular control.
Example 9.3. Overriding scope settings
<a4j:queue requestDelay="2000"/> <h:form> <rich:panel> <h:inputText> <a4j:ajax event="keyup" /> </h:inputText> <a4j:commandButton value="submit"> <a4j:attachQueue requestDelay="0" /> </a4j:commandButton> </rich:panel> </h:form>
The request delay is overridden by the
<a4j:attachQueue> behavior on the submit button.
9.1.7.2. Using a named queue
Name an
<a4j:queue> component using the name attribute. It can then be used by specific components through the <a4j:attachQueue> behavior. Use the name attribute of the <a4j:attachQueue> behavior to identify the name of the destination queue.
Example 9.4. Using a named queue
<a4j:queue name="viewQueue"/> <h:form> <a4j:queue name="formQueue"/> <rich:panel> <a4j:commandButton value="submit"> <a4j:attachQueue name="viewQueue" /> </a4j:commandButton> </rich:panel> </h:form>
The requests from the button are attached to the
viewQueue queue, rather than the formQueue queue.
9.1.7.3. Grouping requests
Use grouping to process multiple requests together. Specify a grouping identifier with the
requestGroupingId attribute. Requests from multiple <a4j:attachQueue> behaviors can use the same identifier to group requests together.
Example 9.5. Grouping requests
<h:form> <a4j:queue requestDelay="2000"/> <h:inputText id="input1" value="#{queueBean.text1}"> <a4j:attachQueue requestGroupingId="registrationForm"/> </h:inputText> <h:inputText id="input2" value="#{queueBean.text2}"> <a4j:attachQueue requestGroupingId="registrationForm"/> </h:inputText> </h:form>
Requests from both the text input boxes are grouped together with the
registrationForm identifier.
9.1.7.4. Reference data
component-type:org.richfaces.AttachQueuecomponent-class:org.richfaces.component.UIAttachQueuecomponent-family:org.richfaces.AttachQueuerenderer-type:org.richfaces.AttachQueueRendererhandler-class:org.richfaces.view.facelets.html.AttachQueueHandler