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...)