You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Markus Stauffer <ma...@gmail.com> on 2007/10/17 13:45:05 UTC

s2 override request_locale

Dear All

Consider the following scenario: The preferred language of the user is
store in the database. I want to override any struts2 i18n settings
when the user logs in. What is stored in the database is of higher
priority than e.g. what the web browser sends in the HTTP request
headers.

How can I achieve my goal? I tried to override the "request_locale"
and "locale" variables with my own Locale. But unfortunately this is
not of a permanent nature for the users session.

Any help is appreciated.

Kind regards
--
Markus Stauffer

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [struts] s2 override request_locale

Posted by Dale Newfield <Da...@Newfield.org>.
Markus Stauffer wrote:
> Another thing that I do not understand is why in the default Interceptor 
> stack the i18n intereceptor is called after the prepare interceptor. In 
> the prepare() methode the Locale is not set, because the i18n interecptor 
> is invoked later in the stack. I had to manualy regroup the defaultStack 
> and swap the i18n and prepare interceptors. Maybe this should be 
> re-arranged in the defaultStack?

If you decide to create a "rearrange interceptors" ticket in JIRA, 
please also suggest that "staticParams" get moved to after "params". 
(And for 2.1.x x>0, that "actionMappingParams" be placed after "params" 
but before "staticParams".)

I mentioned this on the list before, but didn't followup with the 
appropriate JIRA ticket, and it dove-tails really well with your issue...

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: s2 override request_locale

Posted by Markus Stauffer <ma...@gmail.com>.
It is not the best solution to Implement the LovaleProvider and the 
getLocale() method:
Instead I wrote my own Interceptor that manual set the 
Locale "invocation.getInvocationContext().setLocale()".

Another thing that I do not understand is why in the default Interceptor 
stack the i18n intereceptor is called after the prepare interceptor. In 
the prepare() methode the Locale is not set, because the i18n interecptor 
is invoked later in the stack. I had to manualy regroup the defaultStack 
and swap the i18n and prepare interceptors. Maybe this should be 
re-arranged in the defaultStack?

Regards and thanks for all the help
Markus Stauffer



On Wednesday 17 October 2007 14.07:14 Dave Newton wrote:
> Have you tried overriding the getLocale() method of
> ActionSupport-derived classes?
>
> --- Markus Stauffer <ma...@gmail.com> wrote:
> > Dear All
> >
> > Consider the following scenario: The preferred
> > language of the user is
> > store in the database. I want to override any
> > struts2 i18n settings
> > when the user logs in. What is stored in the
> > database is of higher
> > priority than e.g. what the web browser sends in the
> > HTTP request
> > headers.
> >
> > How can I achieve my goal? I tried to override the
> > "request_locale"
> > and "locale" variables with my own Locale. But
> > unfortunately this is
> > not of a permanent nature for the users session.
> >
> > Any help is appreciated.
> >
> > Kind regards
> > --
> > Markus Stauffer
>
> ---------------------------------------------------------------------
>
> > To unsubscribe, e-mail:
> > user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> > user-help@struts.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: s2 override request_locale

Posted by Dave Newton <ne...@yahoo.com>.
Have you tried overriding the getLocale() method of
ActionSupport-derived classes?

--- Markus Stauffer <ma...@gmail.com> wrote:

> Dear All
> 
> Consider the following scenario: The preferred
> language of the user is
> store in the database. I want to override any
> struts2 i18n settings
> when the user logs in. What is stored in the
> database is of higher
> priority than e.g. what the web browser sends in the
> HTTP request
> headers.
> 
> How can I achieve my goal? I tried to override the
> "request_locale"
> and "locale" variables with my own Locale. But
> unfortunately this is
> not of a permanent nature for the users session.
> 
> Any help is appreciated.
> 
> Kind regards
> --
> Markus Stauffer
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org