How to Register Locales and Resource Bundles in Your Application

Internationalizing and Localizing Pages 21-15 The usage format is {adfBundle[ bundleID ] [ resource_Key ]}, where bundleID is the fully qualified bundle ID, such as project.EmpMsgBundle, and resource_Key is the resource key in the bundle, such as Deptno_LABEL. Example 21–8 shows how adfBundle is used to provide the button text with a resource strings from a specific resource bundle. Example 21–8 Binding Using adfBundle af:commandButton text={adfBundle[’project.EmpMsgBundle’] [’Deptno_LABEL’]}

21.3.5 What You May Need to Know About Custom Skins and Control Hints

If you use a custom skin and have created a custom resource bundle for the skin, you must also create localized versions of the resource bundle. Similarly, if your application uses control hints to set any text, you must create localized versions of the generated resource bundles for that text.

21.4 Configuring Pages for an End User to Specify Locale at Runtime

You can configure an application so end users can specify the locale at runtime rather than the default behavior where the locale settings of the end user’s browser determine the runtime locale. Implement this functionality if you want your application to allow end users to specify their preferred locale and save their preference.

21.4.1 How to Configure a Page for an End User to Specify Locale

Create a new page or open an existing page. Configure it so that: ■ It references a backing bean to store locale information ■ An end user can invoke a control at runtime to update the locale information in the backing bean ■ The locale attribute of the f:view tag references the backing bean To configure a page for an end user to specify locale: 1. Create a page with a backing bean to store locale information. For more information, see Section 2.4.1, How to Create JSF JSP Pages . 2. Provide a control for example, a selectOneChoice component that an end user can use to change locale. For example, in the Components Palette, from the Common Components panel, drag and drop a Select One Choice anywhere onto the page. 3. Bind the control to a backing bean that stores the locale value, as illustrated in the following example. af:selectOneChoice label=Select Locale binding={backingBeanScope.backing_changeLocale.soc1} id=soc1 af:selectItem label=French value=FR binding={backingBeanScope.backing_changeLocale.si1} id=si1 ... af:selectOneChoice 21-16 Web User Interface Developers Guide for Oracle Application Development Framework 4. Bind the locale attribute of the f:view tag to the locale value in the backing bean. 1. In the Structure window for the JSF page, right-click the f:view tag and choose Go to Properties. 2. In the Property Inspector, use the dropdown menu next to the locale attribute to open the Expression Builder. 3. Use the Expression Builder to bind to the locale value in the backing bean, as shown in Figure 21–9 . Figure 21–9 Expression Builder Binding the Locale Attribute to a Backing Bean 5. Save the page.

21.4.2 What Happens When You Configure a Page to Specify Locale

JDeveloper generates a reference to the backing bean for the command component that you use to change the locale. Example 21–9 shows an example using the selectOneChoice component. Example 21–9 selectOneChoice Component Referencing a Backing Bean af:selectOneChoice label=Select Locale binding={backingBeanScope.backing_changeLocale.soc1} id=soc1 af:selectItem label=French value=FR binding={backingBeanScope.backing_changeLocale.si1} id=si1 ... af:selectOneChoice JDeveloper also generates the required methods in the backing bean for the page. Example 21–10 shows extracts for the backing bean that correspond to Example 21–9 . Example 21–10 Backing Bean Methods to Change Locale package view.backing; Internationalizing and Localizing Pages 21-17 ... import oracle.adf.view.rich.component.rich.input.RichSelectOneChoice; public class ChangeLocale { ... ... private RichSelectOneChoice soc1; ... ... ... public void setD2RichDocument d2 { this.d2 = d2; } ... public void setSoc1RichSelectOneChoice soc1 { this.soc1 = soc1; } public RichSelectOneChoice getSoc1 { return soc1; } public void setSi1RichSelectItem si1 { this.si1 = si1; } ... } 21.4.3 What Happens at Runtime When an End User Specifies a Locale At runtime, an end user invokes the command component you configured to change the locale of the application. The backing bean stores the updated locale information. Pages where the locale attribute of the f:view tag reference the backing bean render using the locale specified by the end user. The locale specified by the end user must be registered with your application. For more information about specifying a locale and associated resource bundles, see Section 21.3.3, How to Register Locales and Resource Bundles in Your Application . 21.5 Configuring Optional ADF Faces Localization Properties Along with providing text translation, ADF Faces also automatically provides other types of translation, such as text direction and currency codes. The application will automatically be displayed appropriately, based on the user’s selected locale. However, you can also manually set the following localization settings for an application in the trinidad-config.xml file: ■ currency-code: Defines the default ISO 4217 currency code used by oracle.adf.view.faces.converter.NumberConverter to format currency fields that do not specify a currency code in their own converter. ■ number-grouping-separator: Defines the separator used for groups of numbers for example, a comma. ADF Faces automatically derives the separator