<?xml version="1.0" encoding="UTF-8"?>
<chapter id="ArchitectureOverview" xreflabel="ArchitecturalOverview">
  <?dbhtml filename="ArchitectureOverview.html"?>

  <chapterinfo>
    <keywordset>
      <keyword>RichFaces</keyword>

      <keyword>CSS</keyword>

      <keyword>skin</keyword>
    </keywordset>
  </chapterinfo>
  <title>Basic concepts of the RichFaces Framework</title>
  <section id="introToBasics">
    <?dbhtml filename="introToBasics.html"?>
    <title>Introduction</title>
    <para>The framework is implemented as a component library which adds Ajax capability into
      existing pages, so you don&apos;t need to write any JavaScript code or to replace existing
      components with new Ajax widgets. <property>RichFaces</property> enables page-wide Ajax
      support instead of the traditional component-wide support. Hence, you can define the event on
      the page that invokes an Ajax request and the areas of the page that should be synchronized
      with the JSF Component Tree after the Ajax request changes the data on the server according to
      the events fired on the client.</para>
    <para>Next Figure shows how it works:</para>
    <figure>
      <title>Request Processing flow</title>
    </figure>
    <mediaobject>
      <imageobject>
        <imagedata fileref="images/newpic1.png" scalefit="1"/>
      </imageobject>
    </mediaobject>
    <para><property>RichFaces</property> allows to define (by means of JSF tags) different parts of
      a JSF page you wish to update with an Ajax request and provide a few options to send Ajax
      requests to the server. Also JSF page doesn&apos;t change from a
      &quot;regular&quot; JSF page and you don&apos;t need to write any JavaScript or
      XMLHttpRequest objects by hands, everything is done automatically.</para>
  </section>
  <section id="RichFacesArchitectureOverview">
    <?dbhtml filename="RichFacesArchitectureOverview.html"?>
    <title>RichFaces Architecture Overview</title>
    <para>Next figure lists several important elements of the <property>RichFaces</property>
      framework</para>
    <figure>
      <title>Core Ajax component structure</title>
    </figure>
    <mediaobject>
      <imageobject>
        <imagedata fileref="images/newpic2.png"/>
      </imageobject>
    </mediaobject>
    <formalpara>
      <title>Ajax Filter.</title>
      <para>To get all benefits of <property>RichFaces</property>, you should register a Filter in
        web.xml file of your application. The Filter recognizes multiple request types. Necessary
        information about Filter configuration can be found in the <link
          linkend="FilterConfiguration">&quot;Filter configuration&quot;</link> section. The
        sequence diagram on Figure 3 shows the difference in processing of a
        &quot;regular&quot; JSF request and an Ajax request.</para>
    </formalpara>
    <para>In the first case the whole JSF tree will be encoded, in the second one option it depends
      on the &quot;size&quot; of the Ajax region. As you can see, in the second case the
      filter parses the content of an Ajax response before sending it to the client side.</para>
    <para>Have a look at the next picture to understand these two ways:</para>
    <figure>
      <title>Request Processing sequence diagram</title>
    </figure>
    <mediaobject>
      <imageobject>
        <imagedata fileref="images/newpic3.png" scalefit="1"/>
      </imageobject>
    </mediaobject>
    <para>In both cases, the information about required static or dynamic resources that your
      application requests is registered in the ResourseBuilder class.</para>
    <para>When a request for a resource comes (Figure 4), the RichFaces filter checks the Resource
      Cache for this resource and if it is there, the resource is sent to the client. Otherwise, the
      filter searches for the resource among those that are registered by the ResourceBuilder. If
      the resource is registered, the RichFaces filter will send a request to the ResourceBuilder to
      create (deliver) the resource.</para>
    <para>Next Figure shows the ways of resource request processing.</para>
    <figure>
      <title>Resource request sequence diagram</title>
    </figure>
    <mediaobject>
      <imageobject>
        <imagedata fileref="images/newpic4.png" scalefit="1"/>
      </imageobject>
    </mediaobject>
    <formalpara>
      <title>AJAX Action Components</title>
      <para> There are Ajax Action Components: AjaxCommandButton, AjaxCommandLink, AjaxPoll and
        AjaxSupport and etc. You can use them to send Ajax requests from the client side. </para>
    </formalpara>
    <formalpara>
      <title>AJAX Containers</title>
      <para> AjaxContainer is an interface that describes an area on your JSF page that should be
        decoded during an Ajax request. AjaxViewRoot and AjaxRegion are implementations of this
        interface. </para>
    </formalpara>
    <formalpara>
      <title>JavaScript Engine</title>
      <para><property>RichFaces</property> JavaScript Engine runs on the client-side. It knows how
        to update different areas on your JSF page based on the information from the Ajax response.
        Do not use this JavaScript code directly, as it is available automatically. </para>
    </formalpara>
  </section>
  <section id="LimitationsAndRules">
    <?dbhtml filename="LimitationAndRules.html"?>
    <title>Limitations and Rules</title>
    <para>In order to create RichFaces applications properly, keep the following points in mind:</para>
    <itemizedlist>
      <listitem> Any Ajax framework should not append or delete, but only replace elements on the
        page. For successful updates, an element with the same ID as in the response must exist on
        the page. If you&apos;d like to append any code to a page, put in a placeholder for it
        (any empty element). For the same reason, it&apos;s recommended to place messages in the<emphasis>
          <property>&quot;AjaxOutput&quot;</property>
        </emphasis> component (as no messages is also a message). </listitem>
      <listitem> Don&apos;t use <emphasis role="bold">
          <property>&lt;f:verbatim&gt;</property>
        </emphasis> for self-rendered containers, since this component is transient and not saved in
        the tree. </listitem>
      <listitem> Ajax requests are made by XMLHttpRequest functions in XML format, but this XML
        bypasses most validations and the corrections that might be made in a browser. Thus, create
        only a strict standards-compliant code for HTML and XHTML, without skipping any required
        elements or attributes. Any necessary XML corrections are automatically made by the XML
        filter on the server, but lot&apos;s of unexpected effects can be produced by an
        incorrect HTML code. </listitem>
    </itemizedlist>
  </section>

  <section id="AjaxRequestOptimization">
    <?dbhtml filename="AjaxRequestOptimization.html"?>
    <title>Ajax Request Optimization</title>
    <section id="Re-Rendering">
      <?dbhtml filename="Re-Rendering.html"?>
      <title>Re-Rendering</title>
      <para>Ajax attributes are common for Ajax components such as <emphasis role="bold">
          <property>&lt;a4j:support&gt;</property>
        </emphasis>, <emphasis role="bold">
          <property>&lt;a4j:commandButton&gt;</property>
        </emphasis>, <emphasis role="bold">
          <property>&lt;a4j:jsFunction&gt;</property>
        </emphasis>, <emphasis role="bold">
          <property>&lt;a4j:poll&gt;</property>
        </emphasis>, <emphasis role="bold">
          <property>&lt;a4j:push&gt;</property>
        </emphasis> and so on. Also, most RichFaces components with built-in Ajax support have these
        attributes for a similar purpose. Ajax components attributes help RichFaces to expose its
        features. Most of the attributes have default values. Thus, you can start working with
        RichFaces without knowing the usage of these attribute. However, their usage allows to tune
        the required Ajax behavior very smoothly.</para>

      <para><emphasis>
          <property>&quot;reRender&quot;</property>
        </emphasis> is a key attribute. The attribute allows to point to area(s) on a page that
        should be updated as a response on Ajax interaction. The value of the <emphasis>
          <property>&quot;reRender&quot;</property>
        </emphasis> attribute is an id of the JSF component or an id list. </para>
      <para>A simple example is placed below:</para>

      <programlisting role="XML"><![CDATA[...
        <a4j:commandButton value="update" reRender="infoBlock"/>
            ...
        <h:panelGrid id="infoBlock">
            ...
        </h:panelGrid>
...
]]></programlisting>

      <para>The value of <emphasis>
          <property>&quot;reRender&quot;</property>
        </emphasis> attribute of the <emphasis role="bold">
          <property>&lt;a4j:commandButton&gt;</property>
        </emphasis> tag defines which part(s) of your page is (are) to be updated. In this case, the
        only part of the page to update is the <emphasis role="bold">
          <property>&lt;h:panelGrid&gt;</property>
        </emphasis> tag because its ID value matches to the value of <emphasis>
          <property>&quot;reRender&quot;</property>
        </emphasis> attribute. As you see, it&apos;s not difficult to update multiple elements
        on the page, only list their IDs as the value of <emphasis>
          <property>&quot;reRender&quot;</property>
        </emphasis>.</para>

      <para><emphasis>
          <property>&quot;reRender&quot;</property>
        </emphasis> uses <ulink
          url="http://java.sun.com/javaee/javaserverfaces/1.2_MR1/docs/api/javax/faces/component/UIComponent.html#findComponent(java.lang.String)"
          >UIComponent.findComponent() algorithm</ulink> (with some additional exceptions) to find
        the component in the component tree. As can you see, the algorithm presumes several steps.
        Each other step is used if the previous step is not successful. Therefore, you can define
        how fast the component is found mentioning it more precisely. The following example shows
        the difference in approaches (both buttons will work successfully):</para>

      <programlisting role="XML"><![CDATA[...
    <h:form id="form1">
        ...
        <a4j: commandButton value="Usual Way" reRender="infoBlock, infoBlock2" />
        <a4j:commandButton value="Shortcut" reRender=":infoBlockl,:sv:infoBlock2" />
        ...
    </h:form>
    <h:panelGrid id="infoBlock">
        ...
    </h:panelGrid>
    ...
    <f:subview id="sv">
      <h:panelGrid id="infoBlock2">
        ...
      </h:panelGrid>
      ...
    </f:subview>
...
]]></programlisting>

      <para>It&apos;s also possible to use JSF EL expression as a value of the reRender
        attribute. It might be a property of types Set, Collection, Array or simple String. The EL
        for reRender is resolved right before the Render Response phase. Hence, you can calculate
        what should be re-rendered on any previous phase during the Ajax request processing.</para>

      <para>Most common problem with using reRender is pointing it to the component that has a <emphasis>
          <property>&quot;reRender&quot;</property>
        </emphasis> attribute. Note, that JSF does not mark the place in the browser DOM where the
        outcome of the component should be placed in case the <emphasis>
          <property>&quot;rendered&quot;</property>
        </emphasis> condition returns false. Therefore, after the component becomes rendered during
        the Ajax request, RichFaces delivers the rendered code to the client, but does not update a
        page, because the place for update is unknown. You need to point to one of the parent
        components that has no <emphasis>
          <property>&quot;rendered&quot;</property>
        </emphasis> attribute. As an alternative, you can wrap the component with <emphasis
          role="bold">
          <property>&lt;a4j:outputPanel&gt;</property>
        </emphasis> layout=<property>&quot;none&quot;</property>.</para>

      <para><emphasis>
          <property>&quot;ajaxRendered&quot; </property>
        </emphasis> attribute of the <emphasis role="bold">
          <property>&lt;a4j:outputPanel&gt;</property>
        </emphasis> set to <property>&quot;true&quot;</property> allows to define the area
        of the page that will be re-rendered even if it is not pointed in the reRender attribute
        explicitly. It might be useful if you have an area on a page that should be updated as a
        response on any Ajax request. For example, the following code allows to output error
        messages regardless of what Ajax request causes the Validation phase failed. </para>
      <programlisting role="XML"><![CDATA[...
     <a4j:outputPanel ajaxRendered="true">
        <h:messages />
    </a4j:outputPanel>
...
]]></programlisting>

      <para><emphasis>
          <property>&quot;limitToList&quot;</property>
        </emphasis> attribute allows to dismiss the behavior of the <emphasis role="bold">
          <property>&lt;a4j:outputPanel&gt;</property>
        </emphasis>
        <emphasis>
          <property>&quot;ajaxRendered&quot; </property>
        </emphasis> attribute. &quot;limitToList&quot; =
        <property>&quot;false&quot;</property> means to update only the area(s) that
        mentioned in the <emphasis/>&quot;reRender&quot;<property/> attribute explicitly.
        All output panels with
        &quot;ajaxRendered&quot;=<property>&quot;true&quot;</property>is ignored. An
        example is placed below:</para>

      <programlisting role="XML"><![CDATA[...
    <h:form>
       <h:inputText value="#{person.name}">
            <a4j:support event="onkeyup" reRender="test" limitToList="true"/>
        </h:inputText>
        <h:outputText value="#{person.name}" id="test"/>
    </form>
...
]]></programlisting>

    </section>

    <section id="QueueandTrafficFloodProtection">
      <?dbhtml filename="QueueandTrafficFloodProtection.html"?>
      <title>Queue and Traffic Flood Protection</title>
      <para><emphasis>
          <property>&quot;eventsQueue&quot;</property>
        </emphasis> attribute defines the name of the queue that will be used to order upcoming Ajax
        requests. By default, RichFaces does not queue Ajax requests. If events are produced
        simultaneously, they will come to the server simultaneously. JSF implementations
        (especially, the very first ones) does not guaranty that the request that comes first will
        be served or passed into the JSF lifecycle first. The order how the server side data will be
        modified in case of simultaneous request might be unpredictable. Usage of eventsQueue
        attribute allows to avoid possible mess. Define the queue name explicitly, if you expect
        intensive Ajax traffic in your application.</para>
      <para>The next request posted in the same queue will wait until the previos one is not
        processed and Ajax Response is returned back if the <emphasis>
          <property>&quot;eventsQueue&quot;</property>
        </emphasis> attribute is defined. In addition, Richfaces starts to remove from the queue
        &quot;similar&quot; requests. &quot;Similar'&quot;requests are the requests
        produced by the same event. For example, according to the following code, only the newest
        request will be sent to the server if you type very fast and has typed the several
        characters already before the previous Ajax Response is back.</para>

      <programlisting role="XML"><![CDATA[...
    <h:inputText value="#{userBean.name}">
        <a4j:support event="onkeyup" eventsQueue="foo" reRender="bar" />
    </h:inputText>
...
]]></programlisting>

      <para><emphasis>
          <property>&quot;requestDelay&quot;</property>
        </emphasis> attribute defines the time (in ms) that the request will be wait in the queue
        before it is ready to send. When the delay time is over, the request will be sent to the
        server or removed if the newest &quot;similar&quot; request is in a queue already .</para>
      <para><emphasis>
          <property>&quot;ignoreDupResponses&quot;</property>
        </emphasis> attribute orders to ignore the Ajax Response produced by the request if the
        newest &quot;similar&quot; request is in a queue already.
          &quot;ignoreDupResponses&quot;=<property>&quot;true&quot;</property> does
        not cancel the request while it is processed on the server, but just allows to avoid
        unnecessary updates on the client side if the response loses the actuality.</para>
      <para>Defining the <emphasis>
          <property>&quot;eventsQueue&quot;</property>
        </emphasis> along with <emphasis>
          <property>&quot;requestDelay&quot;</property>
        </emphasis> allows to protect against unnecessary traffic flood and synchronizes Ajax
        requests order. If you have several sources of Ajax requests, you can define the same queue
        name there. This might be very helpful if you have Ajax components that invoke request
        asynchronously from the ones produced by events from users. For example, <emphasis
          role="bold">
          <property>&lt;a4j:poll&gt;</property>
        </emphasis> or <emphasis role="bold">
          <property>&lt;a4j:push&gt;</property>
        </emphasis>. In case the requests from such components modify the same data, the
        synchronization might be very helpful.</para>

      <para>More information can be found on the <ulink
          url="http://jboss.com/index.html?module=bb&amp;op=viewtopic&amp;t=105766"
          >RichFaces Users Forum</ulink>.</para>

      <para><emphasis>
          <property>&quot;timeout&quot;</property>
        </emphasis> attribute is used for setting response waiting time on a particular request. If
        a response is not received during this time, the request is aborted.</para>
    </section>

    <section id="DataProcessingOptions">
      <?dbhtml filename="DataProcessingOptions.html"?>
      <title>Data Processing Options</title>
      <para>RichFaces uses form based approach for Ajax request sending. This means each time, when
         you click an Ajax button or <emphasis role="bold">
          <property>&lt;a4j:poll&gt;</property>
        </emphasis> produces an asynchronous request, the data from the closest JSF form is
        submitted with the XMLHTTPRequest object. The form data contains the values from the form
        input element and auxiliary information such as state saving data.</para>
      <para>When <emphasis>
          <property>&quot;ajaxSingle&quot;</property>
        </emphasis> attribute value is <property>&quot;true&quot;</property>, it orders to
        include only a value of the current component (along with <emphasis role="bold">
          <property>&lt;f:param&gt;</property>
        </emphasis> or <emphasis role="bold">
          <property>&lt;a4j:action&gt;</property>
        </emphasis> param values if any) to the request map. In case of <emphasis role="bold">
          <property>&lt;a4j:support&gt;</property>
        </emphasis>, it is a value of the parent component. An example is placed below:</para>

      <programlisting role="XML"><![CDATA[...
    <h:form>
        <h:inputText value="#{person.name}">
            <a4j:support event="onkeyup" reRender="test" ajaxSingle="true"/>
        </h:inputText>
      <h:inputText value="#{person.middleName}"/>
    </form>
...
]]></programlisting>
      <para>In this example the request contains only the input component causes the request
        generation, not all the components contained on a form, because of
          &quot;ajaxSingle&quot;=<property>&quot;true&quot;</property> usage.</para>
      <para>Note, that &quot;ajaxSingle&quot;=<property>&quot;true&quot;</property>
        reduces the upcoming traffic, but does not prevent decoding other input components on the
        server side. Some JSF components, such as <emphasis role="bold">
          <property>&lt;h:selectOneMenu&gt;</property>
        </emphasis> do recognize the missing data in the request map value as a null value and try
        to pass the validation process with a failed result. Thus, use <emphasis role="bold">
          <property>&lt;a4j:region&gt;</property>
        </emphasis> to limit a part of the component tree that will be processed on the server side
        when it is required.</para>
      <para><emphasis>
          <property>&quot;immediate&quot;</property>
        </emphasis> attribute has the same purpose as any other non-JSF component. The default <emphasis>
          <property>&quot;ActionListener&quot;</property>
        </emphasis> should be executed immediately (i.e. during the Apply Request Values phase of a
        request processing lifecycle), rather than waiting until the Invoke Application phase. Using
          immediate=<property>&quot;true&quot;</property> is one of the ways to have some
        data model values updated when other cannot be updated because of a problem with passing the
        Validation phase successfully. This might be important inside the <emphasis role="bold">
          <property>&lt;h:dataTable&gt;</property>
        </emphasis> like components where using <emphasis role="bold">
          <property>&lt;a4j:region&gt;</property>
        </emphasis> is impossible due to the <emphasis role="bold">
          <property>&lt;h:dataTable&gt;</property>
        </emphasis> component architecture.</para>

      <para><emphasis>
          <property>&quot;bypassUpdates&quot;</property>
        </emphasis> attribute allows to bypass the Update Model phase. It might be useful if you
        need to check your input against the available validator, but not to update the model with
        those data. Note, that an action will be invoked at the end of the Validation phase only if
        the Validation phase is passed successfully. The listeners of the Application phase will not
        be invoked in any case.</para>
    </section>

    <section id="ActionandNavigation">
      <?dbhtml filename="ActionandNavigation.html"?>
      <title>Action and Navigation</title>
      <para>Ajax component is similar to any other non-Ajax JSF component like <emphasis role="bold">
          <property>&lt;h:commandButton&gt;</property>
        </emphasis>. It allows to submit the form. You can use <emphasis>
          <property>&quot;action&quot;</property>
        </emphasis> and <emphasis>
          <property>&quot;actionListener&quot;</property>
        </emphasis> attribute to invoke the action method and define the action event.</para>
      <para><emphasis>
          <property>&quot;action&quot;</property>
        </emphasis> method must return null if you want to have an Ajax Response with a partual page
        update. This is regular mode called "Ajax request generates Ajax Response". In case of
        action does not return null, but the action outcome that matches one of navigation rules,
        RichFaces starts to work in "Ajax request generates Non-Ajax Response" mode. This mode might
        be helpful in two major cases:</para>
      <itemizedlist>
        <listitem>RichFaces allows to organize a page flow inside the <emphasis role="bold">
            <property>&lt;a4j:include&gt;</property>
          </emphasis> component. This is a typical scenario for Wizard like behavior. The new
          content is rendered inside the <emphasis role="bold">
            <property>&lt;a4j:include&gt;</property>
          </emphasis> area. The content is taken from the navigation rule of the faces configuration
          file (usually, the faces-config.xml). Note, that the content of the "wizard" is not
          isolated from the rest of the page. The included page should not have own <emphasis
            role="bold">
            <property>&lt;f:view&gt;</property>
          </emphasis> (it does not matter if you use facelets). You need to have an Ajax component
          inside the <emphasis role="bold">
            <property>&lt;a4j:include&gt;</property>
          </emphasis> to navigate between the wizard pages. Otherwize, the whole page update will be
          performed.</listitem>
        <listitem>If you want to involve the server side validators and navigate to the next page
          only if the Validation phase is passed successfully, you can replace <emphasis role="bold">
            <property>&lt;h:commandButton&gt;</property>
          </emphasis> with <emphasis role="bold">
            <property>&lt;a4j:commandButton&gt;</property>
          </emphasis> and point to the action method that navigates to the next page. If Validation
          process fails, the partial page update will occur and you will see an error message.
          Otherwize, the application proceeds to the next page. Make sure, you define
          &lt;redirect/&gt; option for the navigation rule to avoid memory leaks.</listitem>
      </itemizedlist>
      <para> </para>
    </section>

    <section id="JavascriptInteractions">
      <?dbhtml filename="JavascriptInteractions.html"?>
      <title>JavaScript Interactions</title>
      <para>RichFaces allows writing Ajax-enabled JSF application without writing any Javascript
        code. However, you can still invoke the javascript code if you need. There are several ajax
        attributes that helps to do it.</para>
      <para><emphasis>
          <property>&quot;onsubmit&quot;</property>
        </emphasis> attribute allows to invoke JavaScript code before an Ajax request is sent. If <emphasis>
          <property>&quot;onsubmit&quot;</property>
        </emphasis> returns <property>&quot;false&quot;</property>, the Ajax request is
        canceled. The code of <emphasis>
          <property>&quot;onsubmit&quot;</property>
        </emphasis> is inserted before the RichFaces Ajax call. Hence, the <emphasis>
          <property>&quot;onsubmit&quot;</property>
        </emphasis> should not has a &quot;return&quot; statement if you want the Ajax
        request to be sent. If you are going to invoke a JavaScript function that returns
          <property>&quot;true&quot;</property> or
        <property>&quot;false&quot;</property>, use the conditional statement to return
        something only when you need to cancel the request. For example: </para>
      <programlisting role="XML"><![CDATA[...
    onsubmit="if (mynosendfunct()==false){return false}"
...
]]></programlisting>

      <para><emphasis>
          <property>&quot;onclick&quot;</property>
        </emphasis> attribute is similar to the <emphasis>
          <property>&quot;onsubmit&quot;</property>
        </emphasis>, but for clickable components such as <emphasis role="bold">
          <property>&lt;a4j:commandLink&gt;</property>
        </emphasis> and <emphasis role="bold">
          <property>&lt;a4j:commandButton&gt;</property>
        </emphasis>. If it returns <property>&quot;false&quot;</property>, the Ajax request
        is canceled also.</para>
      <para><emphasis>
          <property>&quot;oncomplete&quot;</property>
        </emphasis> attribute allows to invoke the JavaScript code right after the Ajax Response is
        returned back and the DOM tree of the browser is updated. Richfaces registers the code for
        further invocation of XMLHTTP request object before an Ajax request is sent. This means the
        code will not be changed during processing of the request on the server if you use JSF EL
        value binding. Also, you cannot use &quot;this'&quot; inside the code, because it
        will not point the component where Ajax request was initiated.</para>

      <para><emphasis>
          <property>&quot;onbeforedomupdate&quot;</property>
        </emphasis> attrubute defines JavaScript code for call after Ajax response receiving and
        before updating DOM on a client side.</para>

      <para><emphasis>
          <property>&quot;data&quot;</property>
        </emphasis> attribute allows to get the additional data from the server during an Ajax call.
        You can use JSF EL to point the property of the managed bean and its value will be
        serialized in JSON format and be available on the client side. You can refer to it using the <emphasis>
          <property>&quot;data&quot;</property>
        </emphasis> variable. For example:</para>
      <programlisting role="XML"><![CDATA[...
    <a4j:commandButton value="Update" data="#{userBean.name}" oncomplete="showTheName(data.name)" />
...
]]></programlisting>

      <para>Richfaces allows to serialize not only primitive types into JSON format, but also
        complex types including arrays and collections. The beans should be serializable to be
        refered with <emphasis>
          <property>&quot;data&quot;</property>
        </emphasis>.</para>
    </section>

    <section id="IterationcomponentsAjaxattributes">
      <?dbhtml filename="IterationcomponentsAjaxattributes.html"?>
      <title>Iteration components Ajax attributes</title>
      <para><emphasis>
          <property>&quot;ajaxKeys&quot;</property>
        </emphasis> attribute defines strings that are updated after an Ajax request. It provides
        possibility to update several child components separately without updating the whole page.</para>

      <programlisting role="XML"><![CDATA[...
    <a4j:poll intervall="1000" action="#{repeater.action}" reRender="text">
        <table>
            <tbody>
                <a4j:repeat value="#{bean.props}" var="detail" ajaxKeys="#{repeater.ajaxedRowsSet}">
                    <tr>                
                        <td>
                            <h:outputText value="detail.someProperty" id="text"/>
                        </td>                            
                    </tr>
                </a4j:repeat>
            </tbody>
        </table>
    </a4j:poll>
...
]]></programlisting>

    </section>

    <section id="Otherusefulattributes">
      <?dbhtml filename="Otherusefulattributes.html"?>
      <title>Other useful attributes</title>
      <para><emphasis>
          <property>&quot;status&quot;</property>
        </emphasis> attribute for Ajax components (such as <emphasis role="bold">
          <property>&lt;a4j:commandButton&gt;</property>
        </emphasis>, <emphasis role="bold">
          <property>&lt;a4j:poll&gt;</property>
        </emphasis>, etc.) points to an ID of <emphasis role="bold">
          <property>&lt;a4j:status&gt;</property>
        </emphasis> component. Use this attribute if you want to share <emphasis role="bold">
          <property>&lt;a4j:status&gt;</property>
        </emphasis> component between different Ajax components from different regions. The
        following example shows it. </para>

      <programlisting role="XML"><![CDATA[...
    <a4j:region id="extr">
        <h:form>
            <h:outputText value="Status:" />
            <a4j:status id="commonstatus" startText="In Progress...." stopText=""/>
            <h:panelGrid columns="2">
                <h:outputText value="Name"/>
                <h:inputText id="name" value="#{userBean.name}">
                    <a4j:support event="onkeyup" reRender="out" />
                </h:inputText>
                <h:outputText value="Job"/>
                <a4j:region  id="intr">
                    <h:inputText id="job" value="#{userBean.job}">
                        <a4j:support event="onkeyup"  reRender="out" status="commonstatus"/>
                   </h:inputText>
                </a4j:region>
            </h:panelGrid>

            <a4j:region>
                <h:outputText id="out" value="Name: #{userBean.name}, Job: #{userBean.job}" />
                <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>
...
]]></programlisting>

      <para>In the example <emphasis role="bold">
          <property>&lt;a4j:support&gt;</property>
        </emphasis> and <emphasis role="bold">
          <property>&lt;a4j:commandButton&gt;</property>
        </emphasis> are defined in different regions. Values of <emphasis>
          <property>&quot;status&quot;</property>
        </emphasis> attribute for these components points to an ID of <emphasis role="bold">
          <property>&lt;a4j:support&gt;</property>
        </emphasis>.Thus, the <emphasis role="bold">
          <property>&lt;a4j:support&gt;</property>
        </emphasis> component is shared between two components from different regions.</para>

      <para>More information could be found <ulink
          url="http://livedemo.exadel.com/richfaces-demo/richfaces/status.jsf?c=status"
        >here</ulink>.</para>

      <para>Other useful attribute is <emphasis>
          <property>&quot;focus&quot;</property>
        </emphasis>. It points to an ID of a component where focus will be set after an Ajax
        request.</para>

    </section>

  </section>

  <section id="HowTo...">
    <?dbhtml filename="HowTo.html"?>
    <title>How To...</title>
    <section id="SendAnAJAXRequest">
      <?dbhtml filename="SendAnAJAXRequest.html"?>
      <title>Send an Ajax request</title>
      <para>There are different ways to send Ajax requests from your JSF page. For example you can
        use <emphasis role="bold">
          <property>&lt;a4j:commandButton&gt;</property>
        </emphasis>, <emphasis role="bold">
          <property>&lt;a4j:commandLink&gt;</property>, <emphasis role="bold">
            <property>&lt;a4j:poll&gt;</property>
          </emphasis>
        </emphasis> or <emphasis role="bold">
          <property>&lt;a4j:support&gt;</property>
        </emphasis> tags or any other. </para>
      <para>All these tags hide the usual JavaScript activities that are required for an
        XMHttpRequest object building and an Ajax request sending. Also, they allow you to decide
        which components of your JSF page are to be re-rendered as a result of the Ajax response
        (you can list the IDs of these components in the &quot;reRender&quot; attribute). </para>
      <para>
        <emphasis role="bold">
          <property>&lt;a4j:commandButton&gt;</property>
        </emphasis> and <emphasis role="bold">
          <property>&lt;a4j:commandLink&gt;</property>
        </emphasis> tags are used to send an Ajax request on &quot;onclick&quot; JavaScript
        event. </para>
      <para>
        <emphasis role="bold">
          <property>&lt;a4j:poll&gt;</property>
        </emphasis> tag is used to send an Ajax request periodically using a timer. </para>
      <para>The <emphasis role="bold">
          <property>&lt;a4j:support&gt;</property>
        </emphasis> tag allows you to add Ajax functionality to standard JSF components and send
        Ajax request onto a chosen JavaScript event: &quot;onkeyup&quot;,
        &quot;onmouseover&quot;, etc. </para>
      <!--para>Most important attributes of components that provide Ajax request calling features are:</para>
      <itemizedlist>
        <listitem>
          <emphasis>
            <property>&quot;reRender&quot;</property>
          </emphasis>attribute as it was mentioned <link linkend="SendAnAJAXRequest">before</link>
          specifies components to be reRendered after Ajax response. The attribute can be specified
          using EL expression and formed dynamicaly on the server side (see <ulink
            url="index.html#FAQ">FAQ chapter</ulink>). </listitem>
        <listitem>
          <emphasis>
            <property>&quot;RequestDelay&quot;</property>
          </emphasis> attribute is used for a requests frequency regulation. </listitem>
      </itemizedlist>
      <programlisting role="XML"><![CDATA[<h:inputText size="50" value="#{bean.text}">
        <a4j:support event="onkeyup" RequestDelay="3"/>
</h:inputText>]]></programlisting>
      <para>So every next request from the frequent keyboard events will be delayed on 3 ms to
        reduce the number of requests. </para>
      <itemizedlist>
        <listitem>
          <emphasis>
            <property>&quot;EventsQueue&quot;</property>
          </emphasis> is a queue that stores the next request. </listitem>
        <listitem>
          <emphasis>
            <property>&quot;LimitToList&quot;</property>
          </emphasis> attribute is used to regulate updatable regions. Setting it to true limits the
          updatable areas only to ones specified in a reRender list, in other case all Output Panels
          of the region are updated. </listitem>
        <listitem>
          <emphasis>
            <property>&quot;ajaxSingle&quot;</property>
          </emphasis> attributes specify regions to be sent with a request, if
          &quot;false&quot; it is a full region, in other case it&apos;s is only a
          control caused event. </listitem>

        <listitem>
          <emphasis>
            <property>&quot;timeout&quot;</property>
          </emphasis>attribute is used for response waiting time on a particular request. If a
          response is not received during this time, the request is aborted. </listitem>

        <listitem>
          <emphasis>
            <property>&quot;ignoreDupResponses&quot;</property>
          </emphasis> is used to abort unfinished request on new event. </listitem>
      </itemizedlist-->
    </section>



    <section id="DecideWhatToSend">
      <?dbhtml filename="DecideWhatToSend.html"?>
      <title>Decide What to Send</title>
      <para>You may describe a region on the page you wish to send to the server, in this way you
        can control what part of the JSF View is decoded on the server side when you send an Ajax
        request. </para>
      <para>The easiest way to describe an Ajax region on your JSF page is to do nothing, because
        the content between the <emphasis role="bold">
          <property>&lt;f:view&gt;</property>
        </emphasis> and <emphasis role="bold">
          <property>&lt;/f:view&gt;</property>
        </emphasis> tags is considered the default Ajax region. </para>
      <para>You may define multiple Ajax regions on the JSF page (they can even be nested) by using
        the <emphasis role="bold">
          <property>&lt;a4j:region&gt;</property>
        </emphasis> tag. </para>
      <para>If you wish to render the content of an Ajax response outside of the active region then
        the value of the &quot;renderRegionOnly&quot; attribute should be set to
        &quot;false&quot; (&quot;false&quot; is default value). Otherwise, your Ajax
        updates are limited to elements of the active region. </para>
    </section>


    <section id="DecideWhatToChange">
      <?dbhtml filename="DecideWhatToChange.html"?>
      <title>Decide What to Change</title>
      <para>Using IDs in the &quot;reRender&quot; attribute to define &quot;AJAX
        zones&quot; for update works fine in many cases. </para>
      <para>But you can not use this approach if your page contains, e.g. a <emphasis role="bold">
          <property>&lt;f:verbatim&gt;</property>
        </emphasis> tag and you wish to update its content on an Ajax response. </para>
      <para>The problem with the <emphasis role="bold">
          <property>&lt;f:verbatim/&gt;</property>
        </emphasis> tag as described above is related to the value of the transientFlag of JSF
        components. If the value of this flag is true, the component must not participate in state
        saving or restoring of process. </para>
      <para>In order to provide a solution to this kind of problems, RichFaces uses the concept of
        an output panel that is defined by the <emphasis role="bold">
          <property>&lt;a4j:outputPanel&gt;</property>
        </emphasis> tag. If you put a <emphasis role="bold">
          <property>&lt;f:verbatim&gt;</property>
        </emphasis> tag inside of the output panel, then the content of the <emphasis role="bold">
          <property>&lt;f:verbatim/&gt;</property>
        </emphasis> tag and content of other panel&apos;s child tags could be updated on Ajax
        response. There are two ways to control this: <itemizedlist>
          <listitem> By setting the &quot;ajaxRendered&quot; attribute value to
            &quot;true&quot;. </listitem>
          <listitem> By setting the &quot;reRender&quot; attribute value of an Action
            Component to the output panel ID. </listitem>
        </itemizedlist>
      </para>
    </section>
  </section>

  <section id="FilterConfiguration">
    <?dbhtml filename="FilterConfiguration.html"?>
    <title>Filter Configuration</title>
    <para>RichFaces uses a filter for a correction of code received on an Ajax request. In case of a
      &quot;regular&quot; JSF request a browser makes correction independently. In case of
      Ajax request in order to prevent layout destruction it&apos;s needed to use a filter,
      because a received code could differ from a code validated by a browser and a browser doesn't
      make any corrections.</para>

    <para>An example of how to set a Filter in a web.xml file of your application is placed below.</para>

    <para>
      <emphasis role="bold">Example:</emphasis>
    </para>

    <programlisting role="XML"><![CDATA[...
    <filter>
        <display-name>RichFaces Filter</display-name>
        <filter-name>richfaces</filter-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
    </filter>
...
]]></programlisting>

    <note>
      <title>Note:</title>Fast Filter is deprecated and available only for backward compatibility
      with previous RichFaces versions. Fast Filter usage isn&apos;t recomended, because there
      is another way to use its functionality by means of <link linkend="Neko">Neko filter
      type</link>.</note>

    <para>In RichFaces 3.1 filter configuration becomes more flexible. It&apos;s possible to
      configure different filters for different sets of pages for the same application.</para>

    <para>The possible filter types are:</para>

    <itemizedlist>
      <listitem>
        <para>TIDY</para>
      </listitem>
    </itemizedlist>

    <para>&quot;TIDY&quot; filter type based on the Tidy parser. This filter is recommended
      for applications with complicated or non-standard markup when all necessary code corrections
      are made by the filter when a response comes from the server.</para>

    <itemizedlist>
      <listitem>
        <para id="Neko">NEKO</para>
      </listitem>
    </itemizedlist>

    <para>&quot;NEKO&quot; filter type corresponds to the former &quot;Fast
      Filter&quot; and it&apos;s based on the Neko parser. In case of using this filter code
      isn&apos;t strictly verified. Use this one if you are sure that your application markup is
      really strict for this filter. Otherwise it could cause lot&apos;s of errors and corrupt a
      layout as a result. This filter considerably accelerates all Ajax requests processing.</para>

    <itemizedlist>
      <listitem>
        <para>NONE</para>
      </listitem>
    </itemizedlist>

    <para>No correction.</para>

    <para>An example of configuration is placed below.</para>
    <para>
      <emphasis role="bold">Example:</emphasis>
    </para>

    <programlisting role="XML"><![CDATA[...
    <context-param>
        <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
        <param-value>NONE,NEKO,TIDY</param-value>
    </context-param>
 
    <context-param>
        <param-name>org.ajax4jsf.xmlparser.NONE</param-name>
        <param-value>/pages/performance\.xhtml,/pages/default.*\.xhtml</param-value>
    </context-param>

    <context-param>
        <param-name>org.ajax4jsf.xmlparser.NEKO</param-name>
        <param-value>/pages/repeat\.xhtml</param-value>
    </context-param>
    
    <filter> 
        <display-name>RichFaces Filter</display-name> 
        <filter-name>richfaces</filter-name> 
        <filter-class>org.ajax4jsf.Filter</filter-class> 
    </filter>
    
    <filter-mapping> 
        <filter-name>richfaces</filter-name> 
        <servlet-name>Faces Servlet</servlet-name>
        <dispatcher>FORWARD</dispatcher> 
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>INCLUDE</dispatcher> 
    </filter-mapping>
...
]]></programlisting>

    <para>The example shows that ORDER parameter defines the order in which particular filter types
      are used for pages code correction. </para>
    <para> First of all &quot;NONE&quot; type is specified for the filter. Then two
      different sets of pages are defined for which two filter types (NONE and NEKO) are used
      correspondingly. If a page relates to the first set that is defined in the following way: </para>

    <programlisting role="XML"><![CDATA[<param-value>/pages/performance\.xhtml,/pages/default.*\.xhtml</param-value>,
]]></programlisting>

    <para> it&apos;s not corrected, because filter type for this page is defined as
      &quot;NONE&quot;. If a page is not from the first set, then &quot;NEKO&quot;
      type is set.</para>
    <para>If a page relates to the second set that is defined in the following way:</para>

    <programlisting role="XML"><![CDATA[<param-value>/pages/repeat\.xhtml</param-value>,
]]></programlisting>

    <para>then &quot;NEKO&quot; filter type is used for correction. If it&apos;s not
      related to the second set, &quot;TIDY&quot; type is set for the filter
      (&quot;TIDY&quot; filter type is used for code correction). </para>

  </section>
  <section id="ScriptsandStylesLoadStrategy">
    <?dbhtml filename="ScriptsandStylesLoadStrategy" ?>
    <title>Scripts and Styles Load Strategy</title>
    <para>Before the version 3.1.3, RichFaces loaded styles and script on demand. I.e. files are
      loaded only if they are required on a particular page. Since RichFaces 3.1.3, it&apos;s
      possible to manage how the RichFaces script and style files are loaded to application. </para>
    <para>
      <emphasis role="bold">org.richfaces.LoadScriptStrategy </emphasis>
    </para>
    <para>The following declaration in your web.xml allows loading the integrated script files.</para>
    <programlisting role="XML"><![CDATA[...
    <context-param>
          <param-name>org.richfaces.LoadScriptStrategy</param-name>
          <param-value>ALL</param-value>
    </context-param>	
...
]]></programlisting>
    <para>If you do not declare the <property>org.richfaces.LoadScriptStrategy</property> in the
      web.xml, it equals to:</para>
    <programlisting role="XML"><![CDATA[...
    <context-param>
        <param-name>org.richfaces.LoadScriptStrategy</param-name>
        <param-value>DEFAULT</param-value>
    </context-param>	
...
]]></programlisting>
    <para>The third possible value is &quot;NONE&quot;. You have no a special reason to
      use it unless you obtain the newest (or modified) version of the script and want to include
      it manually in a page header. </para>
    
    <note>
      <para>
        If you use &quot;ALL&quot; value of Scripts Load Strategy, make sure you turn the JavaScript files compression off:
      </para>
      <programlisting role="XML"><![CDATA[...
<context-param>
	  <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
	  <param-value>false</param-value>
</context-param>	
...
]]></programlisting>
    </note>
    
    <para>
      <emphasis role="bold">org.richfaces.LoadStyleStrategy</emphasis>
    </para>
    
    <para> The following declaration allows to load only one integrated style sheet file.</para>
    <programlisting role="XML"><![CDATA[...
    <context-param>
          <param-name>org.richfaces.LoadStyleStrategy</param-name>
          <param-value>ALL</param-value>
    </context-param>
...
]]></programlisting>
    <para>The integrated style sheet contains style for all shipped components. The skinnability
      feature still works. </para>
    <para>The &quot;DEFAULT&quot; value is a classical on-demand variant. </para>
    <para>The &quot;NONE&quot; stops loading the styles at all. The earlier introduced
      plain skin resets all color and font parameters to null. The &quot;NONE&quot; value
      for <property>org.richfaces.LoadStyleStrategy</property> means that predefined styles for
      RichFaces are not used.</para>
    <para>For more information see <ulink
      url="http://www.jboss.com/index.html?module=bb&amp;op=viewtopic&amp;p=4114033"
      >RichFaces User Forum</ulink>.</para>
  </section>

  <section id="RequestErrorsAndSessionExpirationHandling">
    <?dbhtml filename="RequestErrorsAndSessionExpirationHandling.html"?>
    <title>Request Errors and Session Expiration Handling</title>
    <para>RichFaces allows to redefine standard handlers responsible for processing of different
      exceptional situations. It helps to define own JavaScript, which is executed when these
      situations occur.</para>
    <section id="RequestErrorsHandling">
      <?dbhtml filename="RequestErrorsHandling.html"?>
      <title>Request Errors Handling</title>
      <para>To execute your own code on the client in case of an error during Ajax request,
        it&apos;s necessary to redefine the standard &quot;A4J.AJAX.onError&quot;
        method:</para>
      <programlisting role="JAVA"><![CDATA[A4J.AJAX.onError = function(req,status,message) { 
          // Custom Developer Code 
};]]></programlisting>
      <para>The function defined this way accepts as parameters:</para>
      <itemizedlist>
        <listitem>req - a params string of a request that calls an error</listitem>
        <listitem>status - the number of an error returned by the server</listitem>
        <listitem>message - a default message for the given error</listitem>
      </itemizedlist>
      <para>Thus, it&apos;s possible to create your own handler that is called on timeouts,
        inner server errors, and etc.</para>
    </section>
    <section id="SessionExpiredHandling">
      <?dbhtml filename="SessionExpiredHandling.html"?>
      <title>Session Expired Handling</title>
      <para>It&apos;s possible to redefine also the <emphasis>
          <property>&quot;onExpired&quot;</property>
        </emphasis> framework method that is called on the <emphasis>
          <property>&quot;Session Expiration&quot;</property>
        </emphasis> event.</para>

      <para>
        <emphasis role="bold">Example:</emphasis>
      </para>

      <programlisting role="JAVA"><![CDATA[A4J.AJAX.onExpired = function(loc,expiredMsg){ 
          // Custom Developer Code 
};
]]></programlisting>

      <para>Here the function receives in params:</para>
      <itemizedlist>
        <listitem>loc - URL of the current page (on demand can be updated) </listitem>
        <listitem>expiredMsg - a default message on <emphasis>
            <property>&quot;Session Expiration&quot;</property>
          </emphasis>event.</listitem>
      </itemizedlist>
      <!--note>
<title>Note:</title>
Until the version 1.0.5 the method can&apos;t be redefined on <emphasis >
     <property>&quot;Session Expiration&quot;</property>,
     </emphasis> a confirmation dialog with a request for view reloading was always called.
</note-->
    </section>
  </section>



  <section id="Skinnability">
    <?dbhtml filename="Skinnability.html"?>
    <title>Skinnability</title>

    <section id="WhySkinnability">
      <?dbhtml filename="WhySkinnability.html"?>
      <title>Why Skinnability</title>

      <para>If you have a look at a CSS file in an enterprise application, for example, the one
        you&apos;re working on now, you&apos;ll see how often the same color is noted in it.
        Standard CSS has no way to define a particular color abstractly for defining as a panel
        header color, a background color of an active pop-up menu item, a separator color, etc. To
        define common interface styles, you have to copy the same values over and over again and the
        more interface elements you have the more copy-and-paste activity that needs to be
        performed.</para>

      <para>Hence, if you want to change the application palette, you have to change all
        interrelating values, otherwise your interface can appear a bit clumsy. The chances of such
        an interface coming about is very high, as CSS editing usually becomes the duty of a general
        developer who doesn&apos;t necessarily have much knowledge of user interface design.</para>

      <para>Moreover, if a customer wishes to have an interface look-and-feel that can be adjusted
        on-the-fly by an end user, your work is multiplied, as you have to deal with several CSS
        files variants, each of which contains the same values repeated numerous times.</para>

      <para>These problems can be solved with the <property>skinnability</property> system built
        into theRichFaces project and realized fully in RichFaces. Every named skin has some
        skin-parameters for the definition of a palette and the other parameters of the user
        interface. By changing just a few parameters, you can alter the appearance of dozens of
        components in an application in a synchronized fashion without messing up user interface
        consistency.</para>

      <para>The <property>skinnability</property> feature can&apos;t completely replace standard
        CSS and certainly doesn&apos;t eliminate its usage. <property>Skinnability</property> is
        a high-level extension of standard CSS, which can be used together with regular CSS
        declarations. You can also refer to skin parameters in CSS via JSF Expression Language. You
        have the complete ability to synchronize the appearance of all the elements in your
      pages.</para>
    </section>

    <section id="UsingSkinnability">
      <?dbhtml filename="UsingSkinnability.html"?>
      <title>Using Skinnability</title>

      <para>RichFaces <property>skinnability</property> is designed for mixed usage with:</para>

      <itemizedlist>
        <listitem>
          <para>Skin parameters defined in the RichFaces framework</para>
        </listitem>

        <listitem>
          <para>Predefined CSS classes for components</para>
        </listitem>

        <listitem>
          <para>User style classes</para>
        </listitem>
      </itemizedlist>

      <para>The color scheme of the component can be applied to its elements using any of three
        style classes:</para>

      <itemizedlist>
        <listitem>
          <para>A default style class inserted into the framework</para>

          <para>This contains style parameters linked to some constants from a skin. It is defined
            for every component and specifies a default representation level. Thus, an application
            interface could be modified by changing the values of skin parameters.</para>
        </listitem>

        <listitem>
          <para>A style class of skin extension</para>

          <para>This class name is defined for every component element and inserted into the
            framework to allow defining a class with the same name into its CSS files. Hence, the
            appearance of all components that use this class is extended.</para>
        </listitem>

        <listitem>
          <para>User style class</para>

          <para>It&apos;s possible to use one of the styleClass parameters for component
            elements and define your own class in it. As a result, the appearance of one particular
            component is changed according to a CSS style parameter specified in the class.</para>
        </listitem>
      </itemizedlist>
    </section>

    <section id="Example">
      <title>Example</title>

      <para>Here is a simple panel component:</para>


      <para>
        <emphasis role="bold">Example:</emphasis>
      </para>
      <programlisting role="XML">&lt;rich:panel&gt;
...
&lt;/rich:panel&gt;</programlisting>

      <para>The code generates a panel component on a page, which consists of two elements: a
        wrapper <emphasis role="bold">
          <property>&lt;div&gt;</property>
        </emphasis> element and a <emphasis role="bold">
          <property>&lt;div&gt;</property>
        </emphasis> element for the panel body with the particular style properties. The wrapper
          <emphasis role="bold">
          <property>&lt;div&gt;</property>
        </emphasis> element looks like:</para>


      <para>
        <emphasis role="bold">Example:</emphasis>
      </para>
      <programlisting role="XML">&lt;div class="dr-pnl rich-panel"&gt;
...
&lt;/div&gt;</programlisting>

      <para>dr-pnl is a CSS class specified in the framework via skin parameters:</para>

      <itemizedlist>
        <listitem>
          <para><property>background-color</property> is defined with
              <property>generalBackgroundColor</property></para>
        </listitem>

        <listitem>
          <para><property>border-color</property> is defined with
            <property>panelBorderColor</property></para>
        </listitem>
      </itemizedlist>

      <para>It&apos;s possible to change all colors for all panels on all pages by changing
        these skin parameters.</para>

      <para>However, if a <emphasis role="bold">
          <property>&lt;rich-panel&gt;</property>
        </emphasis> class is specified somewhere on the page, its parameters are also acquired by
        all panels on this page.</para>

      <para>A developer may also change the style properties for a particular panel. The following
        definition:</para>


      <para>
        <emphasis role="bold">Example:</emphasis>
      </para>
      <programlisting role="XML">&lt;rich:panel styleClass="customClass"&gt;
...
&lt;/rich:panel&gt;</programlisting>

      <para>could add some style properties from customClass to one particular panel, as a result we
        get three styles:</para>


      <para>
        <emphasis role="bold">Example:</emphasis>
      </para>
      <programlisting role="XML">&lt;div class="dr_pnl rich-panel customClass"&gt;
...
&lt;/div&gt;</programlisting>
    </section>

    <section id="SkinParametersTablesInRichFaces">
      <?dbhtml filename="SkinParametersTablesInRichFaces.html"?>

      <title>Skin Parameters Tables in RichFaces</title>

      <para>RichFaces provides eight predefined skin parameters (skins) at the simplest level of
        common customization:</para>

      <itemizedlist>
        <listitem> DEFAULT </listitem>

        <listitem> plain </listitem>

        <listitem> emeraldTown </listitem>

        <listitem> blueSky </listitem>

        <listitem> wine </listitem>

        <listitem> japanCherry </listitem>

        <listitem> ruby </listitem>

        <listitem> classic </listitem>

        <listitem> deepMarine </listitem>
      </itemizedlist>

      <para>To plug one in, it&apos;s necessary to specify a skin name in the <emphasis>
          <property>&quot;org.richfaces.SKIN&quot;</property>
        </emphasis> context-param.</para>

      <para>Here is an example of a table with values for one of the main skins,
          <property>&quot;blueSky&quot;</property>.</para>

      <table>
        <title>Colors</title>

        <tgroup cols="2">
          <thead>
            <row>
              <entry>Parameter name</entry>

              <entry>Default value</entry>
            </row>
          </thead>

          <tbody>
            <row>
              <entry>headerBackgroundColor</entry>

              <entry>#BED6F8</entry>
            </row>

            <row>
              <entry>headerGradientColor</entry>

              <entry>#F2F7FF</entry>
            </row>

            <row>
              <entry>headTextColor</entry>

              <entry>#000000</entry>
            </row>

            <row>
              <entry>headerWeightFont</entry>

              <entry>bold</entry>
            </row>

            <row>
              <entry>generalBackgroundColor</entry>

              <entry>#FFFFFF</entry>
            </row>

            <row>
              <entry>generalTextColor</entry>

              <entry>#000000</entry>
            </row>

            <row>
              <entry>generalSizeFont</entry>

              <entry>11px</entry>
            </row>

            <row>
              <entry>generalFamilyFont</entry>

              <entry>Arial, Verdana, sans-serif</entry>
            </row>

            <row>
              <entry>controlTextColor</entry>

              <entry>#000000</entry>
            </row>

            <row>
              <entry>controlBackgroundColor</entry>

              <entry>#ffffff</entry>
            </row>

            <row>
              <entry>additionalBackgroundColor</entry>

              <entry>#ECF4FE</entry>
            </row>

            <row>
              <entry>shadowBackgroundColor</entry>

              <entry>#000000</entry>
            </row>

            <row>
              <entry>shadowOpacity</entry>

              <entry>1</entry>
            </row>

            <row>
              <entry>panelBorderColor</entry>

              <entry>#BED6F8</entry>
            </row>

            <row>
              <entry>subBorderColor</entry>

              <entry>#ffffff</entry>
            </row>

            <row>
              <entry>tabBackgroundColor</entry>

              <entry>#C6DEFF</entry>
            </row>

            <row>
              <entry>tabDisabledTextColor</entry>

              <entry>#8DB7F3</entry>
            </row>

            <row>
              <entry>trimColor</entry>

              <entry>#D6E6FB</entry>
            </row>

            <row>
              <entry>tipBackgroundColor</entry>

              <entry>#FAE6B0</entry>
            </row>

            <row>
              <entry>tipBorderColor</entry>

              <entry>#E5973E</entry>
            </row>

            <row>
              <entry>selectControlColor</entry>

              <entry>#E79A00</entry>
            </row>

            <row>
              <entry>generalLinkColor</entry>

              <entry>#0078D0</entry>
            </row>

            <row>
              <entry>hoverLinkColor</entry>

              <entry>#0090FF</entry>
            </row>

            <row>
              <entry>visitedLinkColor</entry>

              <entry>#0090FF</entry>
            </row>
          </tbody>
        </tgroup>
      </table>

      <table>
        <title>Fonts</title>

        <tgroup cols="2">
          <thead>
            <row>
              <entry>Parameter name</entry>

              <entry>Default value</entry>
            </row>
          </thead>

          <tbody>
            <row>
              <entry>headerSizeFont</entry>

              <entry>11px</entry>
            </row>

            <row>
              <entry>headerFamilyFont</entry>

              <entry>Arial, Verdana, sans-serif</entry>
            </row>

            <row>
              <entry>tabSizeFont</entry>

              <entry>11px</entry>
            </row>

            <row>
              <entry>tabFamilyFont</entry>

              <entry>Arial, Verdana, sans-serif</entry>
            </row>

            <row>
              <entry>buttonSizeFont</entry>

              <entry>11px</entry>
            </row>

            <row>
              <entry>buttonFamilyFont</entry>

              <entry>Arial, Verdana, sans-serif</entry>
            </row>

            <row>
              <entry>tableBackgroundColor</entry>

              <entry>#FFFFFF</entry>
            </row>

            <row>
              <entry>tableFooterBackgroundColor</entry>

              <entry>#cccccc</entry>
            </row>

            <row>
              <entry>tableSubfooterBackgroundColor</entry>

              <entry>#f1f1f1</entry>
            </row>

            <row>
              <entry>tableBorderColor</entry>

              <entry>#C0C0C0</entry>
            </row>
          </tbody>
        </tgroup>
      </table>

      <para> Skin "plain" was added from 3.0.2 version. It doesn't have any parameters. It's
        necessary for embedding RichFaces components into existing projecst which have its own
        styles. </para>

      <para>To get detailed information on particular parameter possibilities, see the <link
          linkend="RichFacesComponentsLibrary">chapter</link> where each component has skin
        parameters described corresponding to its elements.</para>
    </section>

    <section id="CreatingAndUsingYourOwnSkinFile">
      <?dbhtml filename="CreatingAndUsingYourOwnSkinFile.html"?>
      <title>Creating and Using Your Own Skin File</title>

      <para>In order to create your own skin file, do the following:</para>

      <itemizedlist>
        <listitem>
          <para>Create a file and define in it skin constants which are used by style classes (see
            section <link linkend="SkinParametersTablesInRichFaces">&quot;Skin Parameters Tables
              in RichFaces&quot;</link>). The name of skin file should correspond to the
            following format: <property>&lt;name&gt;.skin.properties</property>. As an
            example of such file you can see RichFaces predefined skin parameters (skins): blueSky,
            classic, deepMarine, etc. These files are located in the richfaces-impl-xxxxx.jar inside
            the /META-INF/skins folder.</para>
        </listitem>

        <listitem>
          <para>Add a skin definition &lt;contex-param&gt; to the web.xml of your
            application. An example is placed below:</para>
          <para>
            <emphasis role="bold">Example:</emphasis>
          </para>
          <programlisting role="XML"><![CDATA[...
    <context-param> 
        <param-name>org.richfaces.SKIN</param-name> 
        <param-value>name</param-value> 
    </context-param>
...
]]></programlisting>
        </listitem>

        <listitem>
          <para>Put your <property>&lt;name&gt;.skin.properties</property> file in one of
            the following classpath elements: META-INF/skins/ or classpath folder (e.g.
            WEB-INF/classes).</para>
        </listitem>
      </itemizedlist>
    </section>
    <section>
      <title>Built-in skinnability in RichFaces</title>
      <para>RichFaces gives an opportunity to incorporate <property>skinnability</property> into UI
        design. With this framework you can easily use named skin parameters in properties files to
        control the appearance of the skins that are applied consistently to a whole set of
        components. You can look at examples of predefined skins at:</para>
      <simplelist>
        <member>
          <ulink url="http://livedemo.exadel.com/richfaces-demo/"
            >http://livedemo.exadel.com/richfaces-demo/</ulink>
        </member>
      </simplelist>
      <para> You may simply control the look-and-feel of your application by using the
          <property>skinnability</property> service of the RichFaces framework. With the means of
        this service you can define the same style for rendering standard JSF components and custom
        JSF components built with the help of RichFaces. </para>
      <para>To find out more on <property>skinnability</property> possibilities, follow these steps:</para>
      <itemizedlist>
        <listitem> Create a custom render kit and register it in the faces-config.xml like this: <programlisting role="XML"><![CDATA[<render-kit>
        <render-kit-id>NEW_SKIN</render-kit-id>
        <render-kit-class> 
            org.ajax4jsf.framework.renderer.ChameleonRenderKitImpl
        </render-kit-class>
</render-kit>]]></programlisting>
        </listitem>
        <listitem> Then you need to create and register custom renderers for the component based on
          the look-and-feel predefined variables: <programlisting role="XML"><![CDATA[<renderer>
        <component-family>javax.faces.Command</component-family> 
        <renderer-type>javax.faces.Link</renderer-type> 
        <renderer-class>
           newskin.HtmlCommandLinkRenderer
        </renderer-class> 
</renderer>]]></programlisting>
        </listitem>
        <listitem> Finally, you need to place a properties file with skin parameters into the class
          path root. There are two requirements for the properties file: <itemizedlist>
            <listitem> The file must be named <emphasis role="bold">
                <property>&lt;skinName&gt;</property>
              </emphasis>.skin.properties, in this case, it would be called
                <filename>newskin.skin.properties</filename>. </listitem>
            <listitem> The first line in this file should be render.kit= <emphasis role="bold"
                  ><property>&lt;render-kit-id&gt;</property>,</emphasis> in this case, it
              would be called render.kit=NEW_SKIN. </listitem>
          </itemizedlist>
        </listitem>
      </itemizedlist>
      <para>Extra information on custom renderers creation can be found at:</para>
      <simplelist>
        <member>
          <ulink url="http://java.sun.com/javaee/javaserverfaces/reference/docs/index.html"
            >http://java.sun.com/javaee/javaserverfaces/reference/docs/index.html</ulink>
        </member>
      </simplelist>
    </section>

  </section>

  <!--section id="OtherRelevantResources">
  <title>Other Relevant Resources</title>
  <para><ulink url="http://jsf.javabeat.net/articles/2007/06/introduction-to-ajax4jsf/">Introduction to Ajax4Jsf</ulink> by Shunmuga Raja</para>
   
</section-->

</chapter>
