JBoss.orgCommunity Documentation
This chapter covers those components that manage the processing of information, requests, and updates.
The <a4j:queue>
component manages a queue of Ajax requests to control message processing.
The size
attribute specifies the number of requests that can be stored in the queue at a time; smaller queue sizes help prevent server overloads. When the queue's size is exceeded, the sizeExceededBehavior
determines the way in which the queue handles the requests:
dropNext
drops the next request currently in the queue.
dropNew
drops the incoming request.
fireNext
immediately sends the next request currently in the queue.
fireNew
immediately sends the incoming request.
The <a4j:queue>
component features several events relating to queuing actions:
The complete
event attribute is fired after a request is completed. The request object is passed as a parameter to the event handler, so the queue is accessible using request.queue
and the element which was the source of the request is accessible using this
.
The requestqueue
event attribute is fired after a new request has been added to the queue.
The requestdequeue
event attribute is fired after a request has been removed from the queue.
The sizeexceeded
event attribute is fired when the queue has been exceeded.
The submit
event attribute is fired before the request is sent.
The success
event attribute is fired after a successful request but before the DOM is updated on the client side.
The <a4j:log>
component generates JavaScript that opens a debug window, logging application information such as requests, responses, and DOM changes.
The popup
attribute causes the logging data to appear in a new pop-up window if set to true
, or in place on the current page if set to false
. The window is set to be opened by pressing the key combination Ctrl+Shift+L; this can be partially reconfigured with the hotkey
attribute, which specifies the letter key to use in combination with Ctrl+Shift instead of L.
The amount of data logged can be determined with the level
attribute:
ERROR
FATAL
INFO
WARN
ALL
, the default setting, logs all data.
The log is automatically renewed after each Ajax request. It does not need to be explicitly re-rendered.
The <a4j:status>
component displays the status of current Ajax requests; the status can be either in progress or complete.
The startText
attribute defines the text shown after the request has been started and is currently in progress. This text can be styled with the startStyle
and startStyleClass
attributes. Similarly, the stopText
attribute defines the text shown once the request is complete, and text is styled with the stopStyle
and stopStyleClass
attributes. Alternatively, the text styles can be customized using facets, with the facet name set to either start
or stop
as required. If the stopText
attribute is not defined, and no facet exists for the stopped state, the status is simply not shown; in this way only the progress of the request is displayed to the user.
The <a4j:status>
component works for each Ajax component inside the local region. If no region is defined, every request made on the page will activate the <a4j:status>
component. Alternatively, the <a4j:status>
component can be linked to specific components in one of two ways:
The for
attribute can be used to specify the component for which the status is to be monitored.
With an id
identifier attribute specified for the <a4j:status>
, individual components can have their statuses monitored by referencing the identifier with their own status
attributes.
Example 8.3. Updating a common <a4j:status>
component
<a4j:region id="extr">
<h:form>
<h:outputText value="Status:" />
<a4j:status id="commonstatus" startText="In Progress...." stopText="" />
<a4j:region id="intr">
<h:panelGrid columns="2">
<h:outputText value="Name" />
<h:inputText id="name" value="#{userBean.name}">
<a4j:support event="keyup" reRender="out" status="commonstatus" />
</h:inputText>
<h:outputText value="Job" />
<h:inputText id="job" value="#{userBean.job}">
<a4j:support event="keyup" reRender="out" status="commonstatus" />
</h:inputText>
<h:panelGroup />
</h:panelGrid>
</a4j:region>
<a4j:region>
<br />
<rich:spacer height="5" />
<b><h:outputText id="out"
value="Name: #{userBean.name}, Job: #{userBean.job}" /></b>
<br />
<rich:spacer height="5" />
<br />
<a4j:commandButton ajaxSingle="true" value="Clean Up Form"
reRender="name, job, out" status="commonstatus">
<a4j:actionparam name="n" value="" assignTo="#{userBean.name}" />
<a4j:actionparam name="j" value="" assignTo="#{userBean.job}" />
</a4j:commandButton>
</a4j:region>
</h:form>
</a4j:region>