This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts2 Localization redirect to current page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 Localization redirect to current page" Watch "Struts2 Localization redirect to current page" New topic

Struts2 Localization redirect to current page

peter wong ka chon
Ranch Hand

Joined: Jul 28, 2011
Posts: 39
I had implemented Struts2 localization from Localization 1 and Localization 2 but both of these tutorial only show how to redirect to the index.jsp which different from my requirement.

My requirement is when user clicks the localization link at addCustomer.jsp, user will redirect to addCustomer.jsp with selected locale rather than to default pages (index.jsp).

How to achieve this?

nir sharma
Ranch Hand

Joined: Sep 11, 2012
Posts: 72

change the jsp inside action with name='locale'. If it doesn't work then post you code.
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 297

hi Peter,

the example were right, you click on addCustomer.jsp, call action onclick and send the parameter . In example it was quoted

To change the default locale, you just need to declared a "request_locale" parameter, set your prefer language code and pass to an Action class. In Struts 2 the com.opensymphony.xwork2.interceptor.I18nInterceptor interceptor, which declared in the struts-default.xml, will hijack your Action class and handle the locale stuff accordingly

so you need to call action return success and on sucess return it to the addcustomer.jsp.. which will work.

peter wong ka chon
Ranch Hand

Joined: Jul 28, 2011
Posts: 39
I have an idea like pass the current page (page="user") as parameter to LocaleAction and the LocaleAction will redirect to the respective page.

I had solved it using the above idea with static mapping on each jsp and lookup using LocaleAction then based on the param return the appropriate string result. Any better idea?
I agree. Here's the link:
subject: Struts2 Localization redirect to current page
It's not a secret anymore!