Your First Cup: An Introduction to the Java EE Platform

Configuring the Resource Bundle in the Configuration File

To make the resource bundle available to the application, you need to configure it in the configuration file, by performing the following task.

ProcedureCreating a Configuration File

The faces-config.xml deployment descriptor contains configuration settings for the JavaServer Faces application. JSF applications don't require a deployment descriptor unless they use features that can only be configured in faces-config.xml. In firstcup, the deployment descriptor has settings defining the resource bundle that provides localized strings in English and Spanish.

  1. Select firstcup in the Projects Pane and select File -> New File.

  2. In the New File dialog, select JavaServer Faces under Categories, new JavaServer Face Configuration under File Types, click Next, then Finish.

ProcedureConfiguring the Resource Bundle

The firstcup application is localized for English and Spanish languages. JavaServer Faces applications can automatically select the proper language based on the locale of the user's web browser. Specify the default and supported locales in the faces-config.xml file.

  1. With the newly created faces-config.xml file open, click XML.

  2. Add the following <application> tag to configure the resource bundle:


    <application>
    	<resource-bundle>
    		<base-name>firstcup.web.WebMessages</base-name>
    		<var>bundle</var>
    	</resource-bundle>
    	<locale-config>
    		<default-locale>en</default-locale>
    		<supported-locale>es</supported-locale>
    	</locale-config>
    </application>

    The base-name element of the resource-bundle element identifies the fully-qualified class name of the resource bundle. The var element identifies the name by which the XHTML pages will reference the resource bundle. The locale-config element identifies the locales supported by the resource bundle.

  3. Right-click in the editor window and select Format.

  4. Select File -> Save.