Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 Localization redirect to current page

 
peter wong ka chon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Thanks.
 
nir sharma
Ranch Hand
Posts: 72
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
change the jsp inside action with name='locale'. If it doesn't work then post you code.
 
jatan bhavsar
Ranch Hand
Posts: 299
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Regards
Jatan
 
peter wong ka chon
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic