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.

ProcedureModify the faces-config.xml File

By default, NetBeans 6.7 IDE creates a Facelets 1.2 configuration file. Modify the faces-config.xml to set the Facelets version to 2.0.

  1. Expand the firstcup module, then Configuration Files in the Projects pane.

  2. Double-click faces-config.xml.

  3. Click XML.

  4. Replace the opening <faces-config> tag with the following:

    <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    			http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
        version="2.0">
  5. Select File->Save.

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. In faces-config.xml add an <application> tag with the following:


    <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.

  2. Select File->Save.