6.9.  < a4j:include >

6.9.1. Description

The <a4j:include> component is used for page areas update after an Ajax request according to the faces-config Navigation Rules and for implementation of wizard-like parts work in Ajax mode.

Table 6.17. a4j : include attributes

Attribute NameDescription
ajaxRenderedDefines, whether the content of this component must be (or not) included in AJAX response created by parent AJAX Container, even if it is not forced by reRender list of ajax action. Ignored if component marked to output by Ajax action. default false
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)
idEvery component may have a unique id that is automatically created if omitted
keepTransientFlag for mark all child components to non-transient. If true, all children components will be set to non-transient state and keep in saved components tree. For output in self-renderer region all content ( By default, all content in <f:verbatim> tags and non-jsf elements in facelets, marked as transient - since, self-rendered ajax regions don't plain output for ajax processing ).
langCode describing the language used in the generated markup for this component
layoutHTML layout for generated markup. Possible values: "block" for generating an HTML <div> element, "inline" for generating an HTML <span> element, and "none" for generating no HTML element. There is a minor exception for the "none" case where a child element has the property "rendered" set to "false". In this case, we create an empty <span> element with same ID as the child element to use as a placeholder for later processing.
renderedIf "false", this component is not rendered
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
viewIdviewId for included page.

Table 6.18. Component identification parameters

NameValue
component-typeorg.ajax4jsf.Include
component-familyjavax.faces.Output
component-classorg.ajax4jsf.component.html.Include
renderer-typeorg.ajax4jsf.components.AjaxIncludeRenderer


6.9.2. Creating on a page

To use the component, it's necessary to place the following strings on a page:

Example:


<h:panelGroup id="wizard">
        <a4j:include  viewId="/pages/include/first.xhtml" />
</h:panelGroup>

For navigation inside a page defined in viewId any components responsible for Ajax requests to the server generation are used.

For example, the following component on a page "/pages/include/first.xhtml"

Example:


...
<a4j:commandButton action="next" reRender="wizard"/>
...

And in faces-config it's defined:

Example:


<navigation-rule>
  <from-view-id>/pages/include/first.xhtml</from-view-id>
  <navigation-case>
   <from-outcome>next</from-outcome>
   <to-view-id>/pages/include/second.xhtml</to-view-id>
  </navigation-case>
 </navigation-rule>

In this case after a click on a button defined inside "first.xhtml" view, navigation is performed after an Ajax request (the same as standard JSF one) only inside this view.

6.9.3. Creating the Component Dynamically Using Java


<import org.ajax4jsf.component.html.Include;
...
Include myInclude = new Include();
...

If <a4j:include> is defined this way, any Ajax request returning outcome inside generates navigation with this <a4j:include> .

Ajax Action for navigation implementation inside view must be placed inside <a4j:include> pages. Navigation defined by these pages is applied to the <a4j:include> element current for them.

As in the general case for Ajax Action component, if the <a4j:action> component inside <a4j:include> returns outcome defined as <redirect/>, Ajax submit is performed with navigation of the whole page and not only of the current view.

6.9.4. Relevant resources links

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

Some additional information can be found on the Ajax4Jsf Users Forum.