Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Struts 1.3.5 i18n problem: redirect to same page after chenging Locale

807606Mar 30 2007
I'm developing a web application in which I have to give the chance to users to change the language at any point of the application.

Something similar to what happens in http://www.fao.org/.

What I have to do is to call a StrutsAction that changes the locale and then reload the page tha called the action WITHOUT re-doing the action.

So actually I should recall the previous action result page without loosing binding. How can I do that with struts 1.3.5?

At the moment, in every action I put a parameter in session with the action's path
(request.getSession().setAttribute(StrutsConstants.USER_LAST_ACTION, request.getServletPath() + "?" + request.getQueryString()););
in my LanguageAction I simply do
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

String language=request.getParameter("language")!=null?request.getParameter("language"):"EN";

Locale locale=new Locale(language);

request.getSession().setAttribute(Globals.LOCALE_KEY, locale);

ActionForward af=new ActionForward((String)request.getSession().getAttribute(StrutsConstants.USER_LAST_ACTION));

return af;

}
but what happens is that the previous action is re-executed (imagine if it was deleting a record from a db, it would generate an error...)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 27 2007
Added on Mar 30 2007
0 comments
236 views