Rather than use an Interceptor I created a filter which does what you describe. 
 I chose a Filter because all requests have to be intercepted and 
pre-processed, and the app has both S1 and S2 pages, and an Interceptor will 
only intercept URLs for S2 actions.  It works perfectly for all pages except 
the Login page.  I have tried storing the Locale in the Session and the 
Request, but neither works for the first page in the app.  I think that it is 
probably an issue with the order in which the ValueStack is created/populated 
and the fact that I'm doing this before the S2 processor catches the request 
(my filter has to come before the S2 filter).  If I knew the S2 context where 
the tags get their localized messages, then I would try to stuff my locale into 
that context.  However, as I noted previously, 
<code>ActionContext.getContext().put(ActionContext.LOCALE, locale);</code> 
doesn't work.  My digging into the source code seemed to tell me that this 
would fill the bill, but no happiness resulted.

Thanks,
- Ray Clough

> ----- Original Message -----
> From: "Laurie Harper" <[EMAIL PROTECTED]>
> To: user@struts.apache.org
> Subject:  Re: Locale - make available to JSP
> Date:  Fri, 03 Aug 2007 18:09:05 -0400
> 
> 
> It sounds like what you want is either to extend the 
> I18nInterceptor to be aware of your cookie, or simply create a 
> custom interceptor that takes care of setting the locale from the 
> cookie into the session (or exposing it as a request parameter for 
> I18nInterceptor to consume), and put that at the front of your 
> interceptor stack.
> 
> L.
> 
> 
> Ray Clough wrote:
> > I really don't see any option to getting the Locale from a 
> > cookie, since this is the first request of a new user session, 
> > and no other facility is available to get it.  The Locale from 
> > the user request won't do, because that is set to the browser 
> > preference, or something.  So the question is "how to make this 
> > Locale available to the S-2 tags in the login page.  The 
> > interceptor doc says it will be saved for "all future requests".  
> > I need to use it for the current request.  It seems that the 
> > solution is to push it to the stack or something, wherever the 
> > S-2 tags get it from.
> >
> > - Ray Clough
> >
> >> ----- Original Message -----
> >> From: "Rene Gielen" <[EMAIL PROTECTED]>
> >> To: "Struts Users Mailing List" <user@struts.apache.org>
> >> Subject: Re: Locale - make available to JSP
> >> Date: Fri, 03 Aug 2007 08:31:22 +0200
> >>
> >>
> >> Could it be that you are looking for I18nInterceptor?
> >>
> >> http://struts.apache.org/2.x/docs/i18n-interceptor.html
> >>
> >> Ray Clough schrieb:
> >>> The first page of my app is a Login page.  Every other page is correctly
> >>> localized, because the app gets the user's preferred locale from a DB, and
> >>> Struts handles it, but until they have logged in the DB is not 
> >>> available.  I
> >>> want it to be localized from cookies.  I created a filter which intercepts
> >>> the requests, gets the cookie from the request, and creates a Locale 
> >>> object
> >>> for that language.  The cookie was stored when the user 
> >>> selected a Locale in
> >>> a previous session.  The question is, where do I store this locale so that
> >>> it is available to the login page.  I looked into the source code for the
> >>> ActionContext class, LocaleProvider class, etc, and it seems like this 
> >>> code
> >>> should work, but it doesn't:   
> >>> ActionContext.getContext().put(ActionContext.LOCALE, locale);
> >>>
> >>> Any help or advise will be greatly appreciated.
> >>>
> >>> Thank you,
> >>> Ray Clough
> >>>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> > - Ray Clough
> > [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

>



- Ray Clough
[EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to