Download
FAQ History |
API
Search Feedback |
Internationalization
The application client and Web client distributed with the Duke's Bank application are internationalized. All strings that appear in the user interfaces are retrieved from resource bundles. The administration client uses resource bundles named
AdminMessages_*.properties
. The Web client uses resource bundles namedWebMessages_*.properties
. Both clients are distributed with English and Spanish resource bundles.The application client retrieves locale information from the command line. For example, to use the Spanish resource bundle, invoke the application this way:
The administration client class
BankAdmin
creates aResourceBundle
that has a locale created from the command-line arguments://Constructor public BankAdmin(Locale currentLocale) { //Internationalization setup messages = ResourceBundle.getBundle("AdminMessages", currentLocale);The Web client
Dispatcher
component retrieves the locale (set by a browser language preference) from the request, opens the resource bundle, and then saves the bundle as a session attribute:ResourceBundle messages = (ResourceBundle)session. getAttribute("messages"); if (messages == null) { Locale locale=request.getLocale(); messages = ResourceBundle.getBundle("WebMessages", locale); session.setAttribute("messages", messages); }The Web client's JavaBeans components access localized messages using
messages.getString("
key
");
.The Web client's JSP pages use the JSTL
fmt:message
tags to retrieve localized messages. You set the localization context of the JSTLfmt
tag library as a context parameter when you package the Web client withdeploytool
.For example, here is how
accountHist.jsp
generates the headings for the transactions table:
Download
FAQ History |
API
Search Feedback |
All of the material in The J2EE(TM) 1.4 Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.