struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carlos Sanchez <apa...@cousas.net>
Subject RE: How to pull messages from multiple Bundles?
Date Wed, 17 Sep 2003 14:01:42 GMT
Oh, sorry, forget my last post and here's an aswer to your problem (which
was also mine)

Watch this from thread "Multiple message resources with JSTL"



> -----Mensaje original-----
> De: Kris Schneider [mailto:kris@dotech.com] 
> Enviado el: viernes, 12 de septiembre de 2003 16:35
> Para: Struts Users Mailing List
> Asunto: Re: Multiple message resources with JSTL
> 
> 
> Here's something that appears to be a step in the right 
> direction. First, use a single context init param for 
> javax.servlet.jsp.jstl.fmt.localizationContext.
> The <param-value> content should match the "parameter" 
> attribute of the <message-resources> element in your default 
> Struts config file. For example, your default Struts config 
> file would include:
> 
> <message-resources parameter="com.obs.webapp.messages.Messages"/>
> 
> Then, add something like the following to a module Struts config file:
> 
> <message-resources 
> parameter="com.obs.webapp.messages.MessagesModule1"/>
> 
> Finally, extend SwitchAction like so:
> 
> import javax.servlet.jsp.jstl.core.Config;
> ...
> public ActionForward execute(ActionMapping mapping,
>                              ActionForm form,
>                              HttpServletRequest request,
>                              HttpServletResponse response) 
> throws Exception {
>   ActionForward forward = super.execute(mapping, form, 
> request, response);
> 
>   ModuleConfig moduleConfig =
>     RequestUtils.getModuleConfig(request, 
> getServlet().getServletContext());
> 
>   MessageResourcesConfig messageConfig =
>     moduleConfig.findMessageResourcesConfig(Globals.MESSAGES_KEY);
> 
>   if (messageConfig != null) {
>     Config.set(request,
>                Config.FMT_LOCALIZATION_CONTEXT,
>                messageConfig.getParameter());
>   }
> 
>   return forward;
> }
> 
> So, as long as you use the new switch action to move between 
> modules, it should pick up the messages associated with the 
> new module and make them available to JSTL. I haven't looked 
> into how to integrate with module switching via a forward 
> with "contextRelative=true", but there might be something 
> possible there as well...
> 
> Quoting Carlos Sanchez <apache@cousas.net>:
> 
> > I'm using JSTL + Struts configured for modules
> > 
> > I'm using JSTL fmt tag for messages, instead of Struts tags, 
> > configured in web.xml
> > 
> >   <context-param>
> >     
> <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</pa
> ram-name>
> >     <param-value>com.obs.webapp.messages.Messages</param-value>
> >   </context-param>
> > 
> > I'd like to add more message resources, one for each module.
> > 
> > Adding more context-param's doesn't work, it uses the last one.
> > 
> > Can I configure it in web.xml, have I to use fmt:setBundle in the 
> > jsps, ...?
> 
> -- 
> Kris Schneider <mailto:kris@dotech.com>
> D.O.Tech       <http://www.dotech.com/>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 



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


Mime
View raw message