You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Anthony Mutiso 2 <an...@utilitynet.net> on 2002/11/07 20:57:07 UTC
working with resource.properties files in JSTL & Struts
What is recognized way to get JSTL <fmt:message> tag to share the same
resources bundle as Struts <bean:message> tag?
Thanks
Anthony
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: working with resource.properties files in JSTL & Struts
Posted by Kris Schneider <kr...@dotech.com>.
I think something like this worked for me with Struts 1.0.2. Not sure if it
will still work with 1.1.
<c_rt:set var="messageResourcesKey"
value="<%= org.apache.struts.action.Action.MESSAGES_KEY %>"/>
<c:set var="messageResources"
value="${applicationScope[messageResourcesKey]}"/>
<c:set var="messageResourcesConfig"
value="${messageResources.config}"/>
<fmt:setBundle basename="${messageResourcesConfig}"
var="messageResourcesBundle"/>
Quoting Anthony Mutiso 2 <an...@utilitynet.net>:
> What is recognized way to get JSTL <fmt:message> tag to share the same
> resources bundle as Struts <bean:message> tag?
>
> Thanks
>
> Anthony
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Kris Schneider <ma...@dotech.com>
D.O.Tech <http://www.dotech.com/>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: working with resource.properties files in JSTL & Struts
Posted by Kris Schneider <kr...@dotech.com>.
Ah, right. That's much simpler for Struts 1.0.2. Except for the fact that
Struts has a hand in how locale is determined. For example, the <html:html> tag
or any piece of application code can set the session attribute named
Action.LOCALE_KEY to a Locale instance. If set, the <bean:message> tag uses
this when it retrieves a message. So, I guess you'd have to add something like:
<c_rt:set var="localeKey"
value="<%= org.apache.struts.action.Action.LOCALE_KEY %>"/>
<fmt:setLocale value="${sessionScope[localeKey]}"/>
If the value attribute of <fmt:setLocale> is null or empty, the runtime's
default Locale is used. I believe this matches the <bean:message> behavior if
Action.LOCALE_KEY is not set.
Of course, this all just pertains to the case where <bean:message> attributes
for bundle and locale are not used.
With 1.1, it looks like things get even hairier...
Quoting Sven Bischoff <sv...@web.de>:
> just place a context-param element in your web.xml as a child of <web-app>.
>
>
> <context-param>
> <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
> <param-value>ApplicationResources</param-value>
> </context-param>
>
> Sven
>
>
> Anthony Mutiso 2 wrote:
> > What is recognized way to get JSTL <fmt:message> tag to share the same
> > resources bundle as Struts <bean:message> tag?
> >
> > Thanks
> >
> > Anthony
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Kris Schneider <ma...@dotech.com>
D.O.Tech <http://www.dotech.com/>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: working with resource.properties files in JSTL & Struts
Posted by Sven Bischoff <sv...@web.de>.
just place a context-param element in your web.xml as a child of <web-app>.
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>ApplicationResources</param-value>
</context-param>
Sven
Anthony Mutiso 2 wrote:
> What is recognized way to get JSTL <fmt:message> tag to share the same
> resources bundle as Struts <bean:message> tag?
>
> Thanks
>
> Anthony
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>