The OpenFaces LoadBundle component is used for loading a resource bundle localized for the Locale of the current view, and expose it (as a Map) in the request attributes of the current request. The <o:loadBundle> component is similar to the standard <f:loadBundle> tag it but can be used in the components with Ajax enabled.

API Reference | Tag Reference

Creating the LoadBundle

The usage of the OpenFaces LoadBundle component is similar to the same component from the Reference or MyFaces JSF implementation. To add the LoadBundle component to the page, use the <o:loadBundle> tag. This tag has only var and basename attributes. The var attribute specifies the name of a request-scope variable under which the resource bundle is available. There are two ways to access keys of the resource bundle:

  1. #{bunble.propertyKey}
  2. #{bundle['propertyKey']}

The basename attribute specifies the path to the resource bundle file. The resource bundle file should be available in the classpath.

Here is an example of the resource bundle in the h:outputText component.

<o:loadBundle basename="my.resources.TestLoadBundle" var="bundle"/>
<h:outputText value="#{bundle.todayString}"/>

In this example the resource bundle is located in WEB-INF/classes/my/resources directory. And there is a "todayString" property key in the TestLoadBundle resource bundle.

In the following example the resource bundle in located in WEB-INF/classes directory and the "todayString" property key is used.

<o:loadBundle basename="TestLoadBundle" var="bundle"/>
<h:outputText value="#{bundle['todayString']}"/>