Create new RichFaces Documentation Jira issue

This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.orgCommunity Documentation

6.1.4.  < a4j:region > available since 3.0.0

expand all
6.1.4.1. Description
6.1.4.2. Details of Usage
6.1.4.3. Reference Data
6.1.4.4. Relevant Resources Links

The <a4j:region> component specifies the part of the component tree to be processed on server. If no <a4j:region> is defined the whole View functions as a region.

The <a4j:region> component specifies the part of the component tree to be processed on server. The processing includes data handling during decoding, conversion, validation and model update. Note that the whole Form is still submitted but only part taken into region will be processed.

Example:


<h:form>
      ...
      <a4j:region>
            <a4j:commandLink/>
      </a4j:region>
      ...
<h:form>

The whole Form on the schematic listing above will be submitted by request invoked with the <a4j:commandLink> . The only part that is going to be processed on the server is enclosed with <a4j:region> and </a4j:region> tags. If no <a4j:region> is defined the whole View functions as a region.

The regions could be nested. Server picks out and decodes only the region, which contains the component that initiates the request.

Example:


<h:form>
       ...
      <a4j:region>
            <a4j:commandLink value="Link 1" id="link1"/>
            <a4j:region>
                 <a4j:commandLink value="Link 2" id="link2"/>
            </a4j:region >
      </a4j:region>
      ...
<h:form>

The external region is decoded for link1 and the internal one is decoded for link2.

The "renderRegionOnly" attribute is used when it is necessary to exclude all the components from the outside of the region from updating on the page during Renderer Response phase. Such manipulation allows region to be passed straight into Encode and reduces performance time. This optimization should be implemented carefully because it doesn't allow data from the outside of active region to be updated.

Example:


<h:form>
       ...
      <a4j:region renderRegionOnly="true">
            <a4j:commandLink value="Link 1" id="link1"/>
      </a4j:region>
       ...
      <a4j:region renderRegionOnly="false">
            <a4j:commandLink value="Link 2" id="link2"/>
      </a4j:region>
       ...
</h:form>

On the example above the first region only will be updated if link1 initiates a request. When a request is initiated by link2 both regions will be updated. In this case search for components to include them into Renderer Response will be performed on the whole component tree.

RichFaces allows setting Ajax responses rendering basing on component tree nodes directly, without referring to the JSP (XHTML) code. This speeds up a response output considerably and could be done by setting the <a4j:region> "selfRendered" attribute to "true". However, this rapid processing could cause missing of transient components that present on view and don't come into a component tree as well as omitting of <a4j:outputPanel> usage described below.

Example:


<a4j:region selfRendered ="true">
      <a4j:commandLink value="Link" id="link"/>
      <!--Some HTML content-->
</a4j:region>

In this case the processing is quicker and going on without referring to the page code. The HTML code is not saved in a component tree and could be lost. Thus, such optimization should be performed carefully and additional RichFaces components usage (e.g. <a4j:outputPanel> ) is required.

Starting from RichFaces 3.2.0 the <a4j:region> can be used together with iterative components (e.g. <rich:column> or <rich:scrollableDataTable> , etc.). It became possible to re-render a particular row in a table without updating the whole table and without any additional listeners.

Example:


<rich:column>
      <a4j:region>
            <a4j:commandLink reRender="out"/>
      </a4j:region>
</rich:column>
<rich:column>
      <h:outputText id="out">
</rich:column>

In most cases there is no need to use the <a4j:region> as ViewRoot is a default one.

Table of <a4j:region> attributes.


Visit <a4j:region> demo page at RichFaces live demo for examples of component usage and their sources.

Useful articles and examples: