One approach you could take would be to create your set of alternate
LocalizationContext instances at application startup and store them in
application scope:
ResourceBundle countriesBundle = ResourceBundle.getBundle("countries", locale);
LocalizationContext countriesCtx = new LocalizationContext(countriesBundle, locale);
servletCtx.setAttribute("countriesCtx", countriesCtx);
ResourceBundle statesBundle = ResourceBundle.getBundle("states", locale);
LocalizationContext statesCtx = new LocalizationContext(statesBundle, locale);
servletCtx.setAttribute("statesCtx", statesCtx);
Then, in your JSP:
<fmt:message bundle="${applicationScope.countriesCtx}" key="message.test">
<fmt:message bundle="${applicationScope.statesCtx}" key="message.test">
Quoting Christian Martin <[EMAIL PROTECTED]>:
> i searched the archive and found a solution to set a LocalizationContext
> in "back-end" java code.
> therefore i don't have to set the bundle in the JSP.
> <code>
> ResourceBundle bundle =
> ResourceBundle.getBundle("ApplicationResources", locale);
> LocalizationContext ctx = new LocalizationContext(bundle);
> Config.set(session, Config.FMT_LOCALIZATION_CONTEXT, ctx);
> </code>
>
> ..following code snippet is not necessary any more
> <code>
> <fmt:setBundle basename="ApplicationResources" var="ares" />
> </code>
>
> so far this works fine.
>
> BUT what do i have to do to set more than one bundle in back-end java code
>
> i did the following (newbie) trial
>
> <code>
> <message-resources parameter="countries" />
> <message-resources parameter="states" />
> </code>
> .....in struts-config.xml
>
> then i want to print out messsages in the jsp.
>
> <code>
> <fmt:message bundle="${countries}" key="message.test">
> <fmt:message bundle="${states}" key="message.test">
> </code>
>
> what is the correct value for parameter bundle?
>
> but as i expected JSTL can't find the messages. ???message.test???
> appears in the browser.
>
> thanks in advance
>
> -------------------------------------------------
> please be patient with the newby
--
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]