Managing the Locale of a Thin Bean

If you support multiple languages in a BI Beans servlet application, then you need to manage the locale of the thin beans that your application incorporates.

For each servlet request in a localized application, you must set the correct locale on the thin beans that your application uses.

Whenever you override the default locale from the servlet request, you must also specify to UIX the new locale.

Setting the Locale for a Thin Bean

To set the locale of a thin bean, you call its setLocale method. After you set the locale, the thin bean loads the appropriate resource bundle for the specified locale. The thin bean then uses that resource bundle every time it renders itself as HTML.

When your servlet receives a new servlet request, you can determine the locale that is set on the request, so that you can set the locale in the thin beans that you create. The determineLocale method of the oracle.cabo.share.util.CaboHttpUtils class provides a convenient way to get the locale from the servlet request.

If you use the UIX determineLocale method, then you do not need to update the UIX locale. When UIX creates the ServletRenderingContext, it calls the same determineLocale method to get the current locale.

Specifying a Locale for UIX

If you set a locale other than the locale from the servlet request, then you must specify the locale to UIX as well as to the thin beans. To override the default UIX locale, call the setLocaleContext method of the oracle.cabo.ui.ServletRenderingContext class. The following code shows how to create a new LocaleContext and to set it in the ServletRenderingContext.


LocaleContext newLocaleContext = new LocaleContext(newLocale("fr", "CA")); // servletRenderingContext is the ServletRenderingContext servletRenderingContext.setLocaleContext(newLocaleContext);

For more information about UIX support for internationalization, see the UIX Developer's Guide.