You might try using a servlet filter to keep the locales in sync:

import javax.servlet.jsp.jstl.core.Config;
...
HttpSession session = request.getSession(true);
Locale locale = (Locale)session.getAttribute(Globals.LOCALE_KEY);
if (locale == null) {
  locale = request.getLocale();
}
Config.set(session, Config.FMT_LOCALE, locale);

Obviously, you can use the Config class from action code as well. Depending on
what type of app server you're using, you'll want a different version of JSTL,
which means different taglib URIs:

JSP 1.2 / JSTL 1.0 (e.g. Tomcat 4):
http://java.sun.com/jstl/fmt

JSP 2.0 / JSTL 1.1 (e.g. Tomcat 5):
http://java.sun.com/jsp/jstl/fmt

Quoting Caoilte O'Connor <[EMAIL PROTECTED]>:

> hey all,
> I'm playing around and trying to get the jstl 
> internationalization tags working with struts. It's proving 
> a bit more of a headache than I'd like.
> 
> I made the usual changes and eventually figured out that the 
> 1.0.0 release (included in the struts 1.1 contrib dir) is 
> seriously broken.
> 
> Now I'm trying to work out the best way to allow users to 
> change locale. Right now I've had to put a
> 
> <fmt:setLocale 
> value='${sessionScope["org.apache.struts.action.LOCALE"]}'/
> >
> 
> at the top of every jsp page using fmt tags otherwise the 
> fmt tags do not pick up on locale changes.
> 
> (I've tried using
> session.setAttribute(Config.FMT_LOCALE, locale);
> 
> in the action where I normally change locale but that didn't 
> work (it was suggested in the archives somewhere.)
> 
> Does anyone know how I can change the fmt locale as part of 
> an action (ie not using the fmt tags)?
> 
> 
> 
> ALSO,
> i had to change the URI of the fmt tag to be "http://
> java.sun.com/jstl/fmt" before it would work properly.
> 
> Are there any other tag libraries with such a "feature"?
> 
> c

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

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

Reply via email to