9.3. <a4j:status>
The
<a4j:status> component displays the status of current Ajax requests. The status can be either in progress, complete, or an error is shown after a failed request.
9.3.1. Customizing the text
The text display can be customized depending on the current status.
- The
startTextattribute defines the text shown after the request has been started and is currently in progress. Set the styles for the text with thestartStyleandstartStyleClassattributes. Alternatively, use thestartfacet to customize the text appearance. - The
stopTextattribute defines the text shown once the request is complete. Set the styles for the text with thestopStyleandstopStyleClassattributes. Alternatively, use thestopfacet to customize the text appearance.If thestopTextattribute is not defined, and no facet exists for the stopped state, the complete status is simply not shown. In this way, only the progress of the request is displayed to the user, along with any errors. - The
errorTextattribute defines the text shown when an error has occurred. Set the styles for the text with theerrorStyleanderrorStyleClassattributes. Alternatively, use theerrorfacet to customize the text appearance.
Example 9.7. Basic <a4j:status> usage
<a4j:status startText="In progress..." stopText="Complete" />
9.3.2. Specifying a region
The
<a4j:status> component monitors the status of the region relevant to where it is placed.
- If unnamed and placed outside any forms, it monitors the status at the view level.
- If unnamed and placed inside a form, it monitors the status at the form level.
However, if identified with the
name attribute, the <a4j:status> component can monitor any Ajax component or behavior. Use the status attribute on the Ajax component or behavior to reference the name identifier of the <a4j:status> component.
Example 9.8. Updating a referenced <a4j:status> component
<rich:panel> <f:facet name="header"> <h:outputText value="User Details Panel" /> </f:facet> <h:panelGrid columns="3"> <h:outputText value="User name:" /> <h:inputText value="#{userBean.name}"> <a4j:ajax status="nameStatus" event="keyup" /> </h:inputText> <a4j:status name="nameStatus"> <f:facet name="start"> <h:graphicImage value="/images/ai.gif" /> </f:facet> </a4j:status> <h:outputText value="Address:" /> <h:inputText value="#{userBean.address}"> <a4j:ajax status="addressStatus" event="keyup" /> </h:inputText> <a4j:status name="addressStatus"> <f:facet name="start"> <h:graphicImage value="/images/ai.gif" /> </f:facet> </a4j:status> </h:panelGrid> </rich:panel>
9.3.3. JavaScript API
The
<a4j:status> component can be controlled through the JavaScript API. The JavaScript API provides the following functions:
start()- Switches status to the
startstate. stop()- Switches status to the
stopstate. error()- Switches status to the
errorstate.
9.3.4. Reference data
component-type:org.richfaces.Statuscomponent-class:org.richfaces.component.UIStatuscomponent-family:org.richfaces.Statusrenderer-type:org.richfaces.StatusRenderer