Language and Font Size Chooser
Each Web Center page displays two controls to let users choose their preferred language and font size. This chapter shows you how to hide one or both controls, adapt their value ranges and define their default values.
Language Chooser
Valid Languages
A valid language is the name of a folder in the directory
WEB-INF/classes/resources/languages.The folder must contain the message file text.properties.
Supported formats are <language> and <language>_<country> with language and country as used by the Java class java.util.Locale, for example de, de_CH, en, en_US.
The standard Web Center applications support the languages de and en.
Configuring the Language Chooser
Labels and values for the language chooser are defined per supported language in file WEB-INF/classes/resources/<language>/text.properties.
The message key for the chooser’s label is application.option.language:
application.option.language = Language:
or, in the German message file:
application.option.language = Sprache:
Labels and values for the supported languages are defined by the message with key application.option.languages. The message text lists each language and its label.
application.option.languages = en:English;de:Deutsch
Defining the Default Language
The default language is defined in file WEB-INF/web.xml by configuration parameter javax.servlet.jsp.jstl.fmt.fallbackLocale:
javax.servlet.jsp.jstl.fmt.fallbackLocale = en
The hard-coded fallback language is en. The value must be one of the valid languages.
Once a user has selected a different language it is stored as part of the login cookie (provided the user accepts the cookie). The cookie is permanently stored on the client for a maximum of 30 days. The cookie language takes precedence over the default language. Note that you can disable login cookies and define a different maximum age in webCenter.properties.
The selected language is also stored in a session variable with name com.siemens.webMgr.language.This assures that the language applies to all requests for the current session even if the cookie is rejected.
Font Size Chooser
Valid Font Size Names
A valid font size name is the name of a folder in the directory
resources/build/styles.The folder must contain the stylesheet styles.css.
The font size names for the standard Web Center applications are small, medium and large.
Available Font Size Names
The list of available font size names must be assigned to configuration parameter availableStyles in file WEB-INF/config/webCenter.properties:
availableStyles = large,medium,small
The list is evaluated on requests to change the font size. If you remove a font size from the list requests to set the font size to that value are ignored even if the size is selectable from the font size chooser.
Configuring the Font Size Chooser
Labels and values for the font size chooser are defined per supported font size in file WEB-INF/classes/resources/<language>/text.properties.
The message key for the chooser’s label is application.option.fontSize:
application.option.fontSize = Font size:
or, in the German message file:
application.option.fontSize = Schriftgröße:
Labels and values for the supported font sizes are defined by the message with key application.option.languages. The message text lists each font size and its label.
application.option.fontSizes = small:Small;medium:Medium;large:Large
Defining the Default Font Size
The default font size is defined by configuration parameter defaultStyle in file WEB-INF/config/webCenter.properties:
defaultStyle = medium
The hard-coded fallback style is medium.
Once a user has selected a different font size it is stored as part of the login cookie (provided the user accepts the cookie). The cookie is permanently stored on the client for a maximum of 30 days. The cookie style takes precedence over the default style. Note that you can disable login cookies and define a different maximum age in webCenter.properties.
The selected style is also stored in a session variable with name com.siemens.webMgr.style.This assures that the style applies to all requests for the current session even if the cookie is rejected.
Removing Both Choosers
The recommended way to remove both the language chooser and the font size chooser from an application is to assign the value “false” to parameter headerOptions in file WEB-INF/config/webCenter.properties:
headerOptions = false
Reset Points
A user can choose another language or style on each Web Center page.That raises the problem of which page to revert to after the change.One cannot simply resend the previous request since this could mean redoing a modification or an assignment, or since the request parameters are no longer available or the session state has changed in between.
If the navigation history is enabled and not empty, the user will be redirected to the most recent page in the history.
If the navigation history is disabled or still empty, the user will be redirected to the last reset point.A reset point is a Struts action to which the application can safely redirect to after having processed a request to change an option.A reset point action must not perform any changes in the database, and should not rely on a specific session state.Web Center keeps track of the last reset point visited per session, and redirects to that action after option changes.
An action is declared a reset point by adding a parameter with name resetPoint and value “true” to the action definition in a struts-config.xml file, for example:
<!-- Action to list users -->
<action path="/getUsers"
type="com.siemens.webMgr.controller.action.JSPAction"
name="userListForm"
parameter="jspPage:/WEB-INF/jsp/controller/core/listObjects.jsp;
resetPoint:true;
...>/