I am developing a web app using Struts 2 which should support multiple locales.
My requirement is the user will be given a dropdown list of all the supporting locales. When the user select a different locale i need to set that locale and redisplay the current page with the changed locale content.
David Newton wrote:You can just return to the page you were on, I suppose. The I18N is handled by the interceptor--if the form tag contains no action it will do a post-back.
problem with post back is previous page/form values are not re-submitted so control goes to 1 page behind complaining to re-submit the values...here is my problem..
i have a very basic requirement to put a toggle link between english and spanish on top of tile (say header.jsp) and this toggle link to be available in all pages in application... So user can change language on any of the page.. My very basic question is that if i follow struts2 documentation, i need to call an action and specify request_locale=en with that action.. But with this approach i will be redirected from my current form/jsp to another one..
i have one common header.jsp which is available in all pages..my flow works that action is executed and on its success a page with tiles is rendered, now on this tiles page (in header.jsp) i want to change language, which means i need to find dynamically what is my current action and then re-send previous request or call this action again with "request_locale=es" as parameter.
- How do i find current or last action in header.jsp?
- how do i re-submit same action with different locale, if i invoke URI for already processed action, it might complain about where previous form values are as it need those again to come to current page? As a matter of fact i will be returned to previous page form.. Am i wrong here
Any sample code, how header.jsp should look like for changing language in any page?if i have to invoke a new action alltogether, how will i come back to my current page. How does i18 work