You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by "::SammyRulez::" <sa...@gmail.com> on 2005/08/26 00:11:54 UTC
message bundle from listener
Hi all
I would like to store in an application scope variable a message
bundle via listener when the application stat up... something like:
public void contextInitialized(ServletContextEvent event) {
ResourceBundle strings = ResourceBundle.getBundle("strings");
event.getServletContext().setAttribute("labels",strings);
}
and retrive the string messages via jstl whit fmt:message
<fmt:message bundle="${labels}" key="appWelcome"/>
but I bump in an exception:
org.apache.jasper.JasperException: jsp.error.beans.property.conversion
org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:885)
any ideas on what obj to use to store string in the application scope
via servlet context?
thanks
--
::SammyRulez::
http://sammyprojectz.blogspot.com
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
Re: message bundle from listener
Posted by Rahul P Akolkar <ak...@us.ibm.com>.
"::SammyRulez::" <sa...@gmail.com> wrote on 08/25/2005 06:11:54 PM:
> Hi all
>
> I would like to store in an application scope variable a message
> bundle via listener when the application stat up... something like:
>
> public void contextInitialized(ServletContextEvent event) {
>
> ResourceBundle strings = ResourceBundle.getBundle("strings");
>
> event.getServletContext().setAttribute("labels",strings);
>
>
> }
>
> and retrive the string messages via jstl whit fmt:message
>
> <fmt:message bundle="${labels}" key="appWelcome"/>
>
> but I bump in an exception:
>
> org.apache.jasper.JasperException: jsp.error.beans.property.conversion
> org.apache.jasper.runtime.JspRuntimeLibrary.
> getValueFromPropertyEditorManager(JspRuntimeLibrary.java:885)
>
>
> any ideas on what obj to use to store string in the application scope
> via servlet context?
<snip/>
javax.servlet.jsp.jstl.fmt.LocalizationContext
i.e.
event.getServletContext().setAttribute("labels", new
LocalizationContext(strings));
And if anyone asks, I insisted on the two argument constructor ;-)
[
http://java.sun.com/products/jsp/jstl/1.1/docs/api/javax/servlet/jsp/jstl/fmt/LocalizationContext.html
]
-Rahul
>
> thanks
>
>
>
> --
> ::SammyRulez::
> http://sammyprojectz.blogspot.com
>