<?xml version='1.0' encoding='UTF-8'?>
<chapter>
  <chapterinfo>
    <keywordset>
      <keyword>a4j:status</keyword>
    </keywordset>
  </chapterinfo>
      <para><table frame="all">
 <title>Component identification parameters</title>
        <tgroup cols="2">
	  <thead>
            <row>
                <entry>Name</entry>
                <entry>Value</entry>
            </row>
       </thead>
          <tbody>
            <row>
              <entry>component-type</entry>
              <entry>org.ajax4jsf.Status</entry>
            </row>
            <row>
              <entry>component-family</entry>
              <entry>javax.faces.Panel</entry>
            </row>
            <row>
              <entry>component-class</entry>
              <entry>org.ajax4jsf.component.html.HtmlAjaxStatus</entry>
            </row>
            <row>
              <entry>renderer-type</entry>
              <entry>org.ajax4jsf.components.AjaxStatusRenderer</entry>
            </row>
          </tbody>
        </tgroup>
      </table></para>
    
    <section>
      <title>Creating on a page</title>
      <para>There are two ways to define elements indicating a request status :</para>
	  <itemizedlist>
          <listitem><para>
            With <emphasis >
                <property>&quot;StartText&quot;/&quot;StopText&quot;</property>
              </emphasis> atributes:</para>
			<programlisting role="XML"><![CDATA[<a4j:status startText="Progress" stopText="Done" for="stat1">]]></programlisting>
            <para>In this case, text elements for the corresponding status are generated.</para>
          </listitem>
        </itemizedlist>
		<itemizedlist>
          <listitem><para>
            With <emphasis><property>&quot;Start&quot;</property></emphasis>/<emphasis><property>&quot;Stop&quot;</property></emphasis > facets definition:</para>
			<programlisting role="XML"><![CDATA[<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>]]></programlisting>
            <para>In this case, the elements are generated for each  status and correspond the facets content.</para>
          </listitem>
        </itemizedlist>
    </section>
	  <section>
      <title>Creating the Component Dynamically Using Java</title>

  <para>
      <emphasis role="bold">Example:</emphasis>
 </para>
	    <programlisting role="JAVA"><![CDATA[import org.ajax4jsf.component.html.HtmlAjaxStatus;
...
HtmlAjaxStatus  myStatus = new HtmlAjaxStatus();
...]]></programlisting>
	  </section>
  <section>
    <title>Facets</title>
    <table>
      <title>Facets</title>
      <tgroup cols="2">
        <thead>
          <row>
            <entry>Facet name</entry>
            <entry>Description</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>start</entry>
            <entry>Redefines the content for display on starting request</entry>
          </row>
          <row>
            <entry>stop</entry>
            <entry>Redefines the content for display on request complete</entry>
          </row>
        </tbody>
      </tgroup>
      
    </table>
  </section>
    <section>
      <title>Key attributes and ways of usage</title>
      <para>There are  two ways for the components or containers definition, which Ajax requests status is tracked by a component.<itemizedlist>
          <listitem><para>
           Definition with the <emphasis >
        <property>&quot;for&quot;</property>
       </emphasis> 
attribute on the <emphasis role="bold">
          <property>&lt;a4j:status&gt;</property>
        </emphasis> component. Here <emphasis >
        <property>&quot;for&quot;</property>
       </emphasis> 
            attribute should point at an Ajax container (<emphasis role="bold"><property>&lt;a4j:region&gt;</property></emphasis>) <property>id</property>, which requests are tracked by a component.
          </para></listitem>
        </itemizedlist><itemizedlist>
          <listitem><para>
            Definition with the <emphasis >
        <property>&quot;status&quot;</property>
       </emphasis> 
attribute obtained by any RichFaces library action component. The attribute should point at the <emphasis role="bold">
          <property>&lt;a4j:status&gt;</property>
</emphasis>  component <property>id</property>. Then this  <emphasis role="bold">
          <property>&lt;a4j:status&gt;</property>
        </emphasis> component   shows the status for the request fired from this action component.
          </para></listitem>
        </itemizedlist></para>
      <para>The component creates two <emphasis role="bold"><property>&lt;span&gt;</property></emphasis> or <emphasis role="bold"><property>&lt;div&gt;</property></emphasis>
        elements depending on attribute <emphasis><property>&quot;layout&quot;</property></emphasis>
	  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.</para>
      <para><emphasis role="bold">Example:</emphasis>
      </para>
	  <programlisting role="XML"><![CDATA[<a4j:status startText="Started" stopText="stopped" />]]></programlisting>
      <para>The code shown in the example above is decoded on a page as:</para><programlisting role="XML"><![CDATA[<span id="j_id20:status.start" style="display: none">
      Started
</span>
<span id="j_id20:status.stop">
        Stopped
</span>]]></programlisting>
      <para>and after the generation of an Ajax response is changed to:</para>
	  <programlisting role="XML"><![CDATA[<span id="j_id20:status.start">
        Started
</span>
<span id="j_id20:status.stop" style="display: none">
        Stopped
</span>]]></programlisting>
      <para>There is a possibility to group a <emphasis role="bold"><property>&lt;a4j:status&gt;</property></emphasis> elements content into <emphasis role="bold"><property>&lt;div&gt;</property></emphasis> elements, instead of <emphasis role="bold"><property>&lt;span&gt;</property></emphasis>. To use it, just redefine the <emphasis >
        <property>&quot;layout&quot;</property>
       </emphasis> 
        attribute from &quot;inline&quot; (default) to &quot;block&quot;.</para>
    </section>
  <section>
    <title>Relevant resources links</title>
    <para>
    	<ulink
    		url="http://wiki.jboss.org/wiki/RichFacesPleaseWaitBox">
    		Here
    	</ulink>
    	you can find information on how to show a &quot;Please Wait&quot; box and
    	block the input while the Ajax request is processed using combination of
    	<emphasis role="bold">
    		<property>&lt;a4j:status&gt;</property>
    	</emphasis>
    	and
    	<emphasis role="bold">
    		<property>&lt;rich:modalPanel&gt;</property>
    	</emphasis>
		components
    	.
    </para>
    <para>
	  <ulink url="http://livedemo.exadel.com/richfaces-demo/richfaces/status.jsf?c=status">Here</ulink>  you can see the example of <emphasis role="bold"
	    ><property>&lt;a4j:status&gt;</property></emphasis> usage and sources for the given example. 
	</para>
  </section>	
</chapter>
