tags:

views:

78

answers:

1

I am using struts2 and in my struts.xml I have written following code for locale switching -

<action name="switchToEnglish">
         <interceptor-ref name="i18n"/>
         <interceptor-ref name="basicStack"/>
         <result name="input">error.jsp</result>
         <result name="success">login.jsp</result>
</action>

<action name="switchToFrench">
         <interceptor-ref name="i18n"/>
         <interceptor-ref name="basicStack"/>
         <result name="input">error.jsp</result>
         <result name="success">login.jsp</result>
</action>

Now, after language switching same page (login.jsp) appears. But, I want to return on the page where user was before language switching.

Thanks in advance.

A: 

I had the same problem. I resolved it by passing the page name to the action(by GET or POST), then I use it in the result this way :

<action name="switchToEnglish">
     <interceptor-ref name="i18n"/>
     <interceptor-ref name="basicStack"/>
     <result name="input">error.jsp</result>
     <result name="success">%{currentPage}</result>
</action>

<action name="switchToFrench">
     <interceptor-ref name="i18n"/>
     <interceptor-ref name="basicStack"/>
     <result name="input">error.jsp</result>
     <result name="success">%{currentPage}</result>
</action>

Don't forget to set the getter/setter for "currentPage" in the action Class.

It's not the best way to do it but it was ok for my app.

elblanco