The <a4j:loadBundle> component is similar to the same component from the JSF Core library. The component loads a resource bundle localized for the Locale of the current view and exposes it (as a Map) in the request attributes of the current request.
Table 6.19. a4j : loadBundle attributes
Attribute Name | Description |
---|---|
basename | Base name of the resource bundle to be loaded. |
binding | The attribute takes a value-binding expression for a component property of a backing bean |
id | Every component may have a unique id that is automatically created if omitted |
rendered | If "false", this component is not rendered |
var | Name of a request scope attribute under which the resource bundle will be exposed as a Map. |
Table 6.20. Component identification parameters
Name | Value |
---|---|
component-type | org.ajax4jsf.Bundle |
component-family | org.ajax4jsf.Bundle |
component-class | org.ajax4jsf.component.html.AjaxLoadBundle |
To create the simplest variant on a page use the following syntax:
Example:
<a4j:loadBundle baseName="demo.bundle.Messages" var="Message"/>
Example:
import org.ajax4jsf.component.html.AjaxLoadBundle;
...
AjaxLoadBundle myBundle = new AjaxLoadBundle();
...
<a4j:loadBundle> allows to use reference to bundle messages during the Ajax re-rendering. <a4j:loadBundle> is a substitute for the <f:loadBundle> in JSF 1.1 which is not a JSF component originally. <f:loadBundle> is a jsp tag that load the bundle messages into the request scope when page is rendered. As soon as each Ajax request works in own request scope, the bundles loaded with <f:loadBundle> are unavailable. Instead of <f:loadBundle> that might be located anywhere on a page, the <a4j:loadBundle> should be declared inside the <f:view> (this does not matter in case on using Facelets) JSF 1.2 introduces the bundle registered in the faces-config.xml. This fixed the problem with <f:loadBundle> . Therefore, you can use this JSF 1.2 way to declare your bundles.