Using resource bundles in store pages

A new programming direction has been undertaken with our starter stores that now use the JavaServer Pages Standard Tag Library (JSTL) to perform view logic, instead of Java code.

About this task

This changes the way we use resource bundles with store pages. At run time, each requested JSP includes the JSTLEnvironmentSetup.jspf file. This file retrieves and prepares the JSP page path, file path, and resource bundle, which are used by other JSP pages. This file is called by many JSP files in the store. The command context and locale are retrieved as shown:

LocalizationContext storeDynamicTextContext = (LocalizationContext)
if (storeDynamicTextContext == null){
CommandContext cmdcontext = (CommandContext)
Locale locale = cmdcontext.getLocale();

The locale is used to retrieve appropriate locale specific ResourceBundle (properties file) through a call to the sdb.getResourceBundle as shown in the following example:

<wcbase:useBean id="sdb"
scope="request" />
storeDynamicTextContext = new
request.setAttribute("storeDynamicText", storeDynamicTextContext);

Dynamic data is retrieved at runtime using various server bean methods and is performed in the context of the current language. The returned value for the language parameter (language_ID) determines the language in which the store name displays. The displayName method of the StoreDataBean retrieves this value. The following example shows the request for the language-specific store display name:

<c:set var="storeName"
scope="page" />

The locale and language are retrieved at runtime to determine the correct folder in which to look for the image file.

<c:set var="locale" value="${CommandContext.locale}"
scope="page" />
<c:set var="langId" value="${CommandContext.languageId}"
scope="page" />

For example, the template may look for the file ConsumerDirect/ lang_country/images/colors/color1/go_button.gif, where lang_country is the language_region part of the locale retrieved from the command context. The resulting page will display the image: ConsumerDirect/en_US/images/colors/color1/go_button.gif ConsumerDirect/ja_JP/images/colors/color1/go_button.gif