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 12:07:12 GMT
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