Application-Wide Locale Changing Functionality in Struts 1.1
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ken_Rosha
Posted On:   Sunday, July 27, 2003 10:59 AM

I have looked through a number of the postings in this forum regarding Locale/language changing in the Struts 1.1 framework, but I have not found a definitive guide or solution to implementing application-wide locale change functionality. Here is what I am trying to do. As part of the header (or footer) of each page in the application, I want to allow the user to select/change their preferred language from a drop-down list of supported languages. The drop-down list of languages itself also needs to be localized to the currently selected user locale, i.e. if the currently selected user locale is French, the display name of each supported language in the list should appear in French. Once a language selection has been made, an automatic form s   More>>

I have looked through a number of the postings in this forum regarding Locale/language changing in the Struts 1.1 framework, but I have not found a definitive guide or solution to implementing application-wide locale change functionality.


Here is what I am trying to do. As part of the header (or footer) of each page in the application, I want to allow the user to select/change their preferred language from a drop-down list of supported languages. The drop-down list of languages itself also needs to be localized to the currently selected user locale, i.e. if the currently selected user locale is French, the display name of each supported language in the list should appear in French. Once a language selection has been made, an automatic form submit should be done which causes the currently displayed form to be redisplayed again in the newly selected language.


Here are some possibitities that come to my mind:


1) Place a small html:form in the header which contains only the drop-down list of languages, which, when onChange occurs, submits the form to an Action called ChangeLocaleAction. Create a ChangeLocaleAction and ChangeLocaleForm to manage language change, save the new locale to the user's session, and then redirect the request back to the initiating page.


2) Create a BaseLocaleForm, which all forms in the application must extend and which contains the selected locale as its sole property. Create a BaseLocaleAction, which all actions in the application must extend and which detects and processes the locale change in its execute() method, saving the new locale to the user's session, and then forwarding the request to the initiating page.


3) Create a BaseRequestProcessor, which checks each incoming request for a locale change, saves the new locale to the user's session, and then forwards the request to the initiating page.


If anyone has tried to implement this locale-changing functionality on an application-wide basis, I would really like to learn of your experiences and how you've solved this problem.

   <<Less
About | Sitemap | Contact