6.22.  < a4j:status >

6.22.1. Description

The <a4j:status> component generates elements for displaying of the current Ajax requests status. There are two status modes: Ajax request is in process or finished.

Table 6.43. a4j : status attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
forID of the AjaxContainer component whose status is indicated (in the format of a javax.faces.UIComopnent.findComponent() call).
forceIdIf true, render the ID of the component in HTML code without JSF modifications.
idEvery component may have a unique id that is automatically created if omitted
langCode describing the language used in the generated markup for this component
layoutDefine visual layout of panel, can be "block" or "inline".
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onstartJavaScript code, called on the start of a request.
onstopJavaScript code, called on the stop of a request.
renderedIf "false", this component is not rendered
startStyleCSS style class for the element displayed on the start of a request.
startStyleClassCSS style class for the element displayed on the start of a request.
startTextText for display on starting request.
stopStyleCSS style for element displayed on request completion.
stopStyleClassCSS style class for element displayed on request
stopTextText for display on request complete.
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
titleAdvisory title information about markup elements generated for this component

Table 6.44. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Status
component-familyjavax.faces.Panel
component-classorg.ajax4jsf.component.html.HtmlAjaxStatus
renderer-typeorg.ajax4jsf.components.AjaxStatusRenderer


6.22.2. Creating on a page

There are two ways to define elements indicating a request status :

  • With "StartText"/"StopText" atributes:

    
    <a4j:status startText="Progress" stopText="Done" for="stat1">

    In this case, text elements for the corresponding status are generated.

  • With "Start"/"Stop" facets definition:

    
    <a4j:status for="stat2">
        <f:facet name="start">
            <h:graphicImage value="ajax_process.png" />
        </f:facet>
        <f:facet name="stop">
            <h:graphicImage value="ajax_stoped.png" />
        </f:facet>
    </a4j:status>

    In this case, the elements are generated for each status and correspond the facets content.

6.22.3. Creating the Component Dynamically Using Java

Example:


import org.ajax4jsf.component.html.HtmlAjaxStatus;
...
HtmlAjaxStatus  myStatus = new HtmlAjaxStatus();
...

6.22.4. Key attributes and ways of usage

There are two ways for the components or containers definition, which Ajax requests status is tracked by a component.

  • Definition with the "for" attribute on the <a4j:status> component. Here "for" attribute should point at an Ajax container ( <a4j:region> ) id, which requests are tracked by a component.

  • Definition with the "status" attribute obtained by any RichFaces library action component. The attribute should point at the <a4j:status> component id. Then this <a4j:status> component shows the status for the request fired from this action component.

The component creates two <span> or <div> elements depending on attribute "layout" with content defined for each status, one of the elements (start) is initially hidden. At the beginning of an Ajax request, elements state is inversed, hence the second element is shown and the first is hidden. At the end of a response processing, elements display states return to its initial values.

Example:


<a4j:status startText="Started" stopText="stopped" />

The code shown in the example above is decoded on a page as:


<span id="j_id20:status.start" style="display: none">
      Started
</span>
<span id="j_id20:status.stop">
        Stopped
</span>

and after the generation of an Ajax response is changed to:


<span id="j_id20:status.start">
        Started
</span>
<span id="j_id20:status.stop" style="display: none">
        Stopped
</span>

There is a possibility to group a <a4j:status> elements content into <div> elements, instead of <span> . To use it, just redefine the "layout" attribute from "inline"(default) to "block".

6.22.5. Relevant resources links

Here you can see the example of <a4j:status> usage and sources for the given example.