tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <k...@dotech.com>
Subject Re: Using Config.set(session, Config.FMT_LOCALE, locale);
Date Fri, 13 Aug 2004 15:05:56 GMT
Well, if it works, it works ;-). Anything bundled with Struts is likely to be a
flavor of Standard 1.0 because of the Struts-EL taglib. I have no idea what
version comes along for the ride, but the most recent is Standard 1.0.6. If
you're running in a JSP 2.0 environment, Struts-EL is irrelevent and you should
certainly use JSTL 1.1. If you still need JSP 1.2 compatibility, try replacing
the Standard JARs that come with Struts with Standard 1.0.6 and see if that
works. I've got a slightly more involved example app that works with Standard
1.0.6 and a Filter to set the locale if you want to look at some more code...

Quoting Bill Siggelkow <billsigg@bellsouth.net>:

> Yes, that's essentially what I was doing ... interestingly enough, I 
> solved the problem by updating to taglibs-standard 1.1.1. Before I was 
> using the jstl.jar and standard.jar included in Struts 1.2.1.
> 
> Kris Schneider wrote:
> > Strange, because the following seems to work:
> > 
> > web.xml:
> > --------
> > <web-app>
> >     ....
> >     <context-param>
> >        
> <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
> >         <param-value>Messages</param-value>
> >     </context-param>
> >     ....
> > </web-app>
> > 
> > WEB-INF/classes/Messages.properties:
> > ------------------------------------
> > msg=Messages
> > 
> > WEB-INF/classes/Messages_ru.properties:
> > ---------------------------------------
> > msg=Messages_ru
> > 
> > fmtlocale.jsp:
> > --------------
> > <%@ page contentType="text/plain" %>
> > <%@ page import="java.util.Locale" %>
> > <%@ page import="javax.servlet.jsp.jstl.core.Config" %>
> > <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
> > 
> > <% Config.set(session, Config.FMT_LOCALE, new Locale("ru")); %>
> > 
> > msg: <fmt:message key="msg"/>
> > 
> > output:
> > -------
> > msg: Messages_ru
> > 
> > Is that basically the equivalent of what you're doing?
> > 
> > Quoting Bill Siggelkow <billsigg@bellsouth.net>:
> > 
> > 
> >>I have created a Struts action similar to one suggested by Kris 
> >>Schneider to change the current locale for both Struts and JSTL.
> >>
> >>In the action after creating a locale based on user input I make the 
> >>following two calls:
> >>
> >>	// reset the Struts locale
> >>         session.setAttribute(Globals.LOCALE_KEY, locale);
> >>
> >>         // reset the JSTL locale
> >>         Config.set(session, Config.FMT_LOCALE, locale);
> >>
> >>I then redirect to the page where I display some text based on the locale.
> >>
> >>The Struts bean:message works perfectly - however, the JSTL fmt:message 
> >>does not work -- by the way, I do have the LocalizationContext pointing 
> >>to my ApplicationResources through the web.xml context-param.
> >>
> >>Interestingly enough, if I do use <fmt:setLocale locale="ru"/> on the 
> >>before the <fmt:message key="foo"/> it works!
> >>
> >>Does anyone have any ideas on why the Config.set(...) is not working?
> >>
> >>Bill Siggelkow

-- 
Kris Schneider <mailto:kris@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


Mime
View raw message