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 startText attribute defines the text shown after the request has been started and is currently in progress. Set the styles for the text with the startStyle and startStyleClass attributes. Alternatively, use the start facet to customize the text appearance.
  • The stopText attribute defines the text shown once the request is complete. Set the styles for the text with the stopStyle and stopStyleClass attributes. Alternatively, use the stop facet to customize the text appearance.
    If the stopText attribute 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 errorText attribute defines the text shown when an error has occurred. Set the styles for the text with the errorStyle and errorStyleClass attributes. Alternatively, use the error facet 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 start state.
stop()
Switches status to the stop state.
error()
Switches status to the error state.

9.3.4. Reference data

  • component-type: org.richfaces.Status
  • component-class: org.richfaces.component.UIStatus
  • component-family: org.richfaces.Status
  • renderer-type: org.richfaces.StatusRenderer