You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Jain, Shipra" <Sh...@GTECH.COM> on 2001/07/07 00:01:03 UTC

More than one resource bundles.

Hi

I am a new user of Struts.  I wanted more than one resource bundles for my
application. For e.g., One resources bundle will contain all message
strings( MessageResources). Another contains all the images.  (
ImageResources )
What I understand is that using  Struts Img tag , I can specify key to the
src attribute for this generated tag. Also, using bundle attribute of the
Img Tag, I can specify a different bundle other than the default one loaded
by 
<init-param> 
<param-name>application</param-name> 
<param-value>MessageResources</param-value> 
 </init-param> 
in the web.xml.
But when I use this bundle attribute , it gives me following error.
javax.servlet.jsp.JspException 
java.lang.Throwable(java.lang.String)
java.lang.Exception(java.lang.String)
javax.servlet.jsp.JspException(java.lang.String) 
java.lang.String
org.apache.struts.util.RequestUtils.message(javax.servlet.jsp.PageContext,
java.lang.String, java.lang.String, java.lang.String, java.lang.Object []) 
java.lang.String
org.apache.struts.util.RequestUtils.message(javax.servlet.jsp.PageContext,
java.lang.String, java.lang.String, java.lang.String)
java.lang.String org.apache.struts.taglib.html.ImgTag.src() 
int org.apache.struts.taglib.html.ImgTag.doEndTag() 
My jsp code looks like 
<html:img  bundle="ImageResources" srcKey="img.i1" />
If I remove bundle from here & put the img.i1 key in my default
MessageResources, it works fine. But as mentioned earlier , I want a
separation between the two kind of resources.
So , my question is if I am using the bundle attribute of ImgTag correctly &
where do I keep my ImageResources File or preferably specify path to it ?
Thanks in advance of all the answers.
Shipra Jain
Web Developer
GTECH Corporation
 

Re: More than one resource bundles.

Posted by Martin Cooper <ma...@tumbleweed.com>.
The 'bundle' attribute specifies the name of the (application, or servlet
context) attribute under which the loaded message resources are used. To use
a second bundle, you will have to load it yourself and store it as an
attribute, so that your JSPs can access it.

Probably the best way to load additional bundles is by extending
ActionServlet and overriding one of the init* methods. (The initApplication
method is where Struts loads the 'application' bundle.) That way, the bundle
will always be loaded before any of your Actions are processed.

Hope this helps.

--
Martin Cooper


----- Original Message -----
From: "Jain, Shipra" <Sh...@GTECH.COM>
To: <st...@jakarta.apache.org>
Sent: Friday, July 06, 2001 3:01 PM
Subject: More than one resource bundles.


> Hi
>
> I am a new user of Struts.  I wanted more than one resource bundles for my
> application. For e.g., One resources bundle will contain all message
> strings( MessageResources). Another contains all the images.  (
> ImageResources )
> What I understand is that using  Struts Img tag , I can specify key to the
> src attribute for this generated tag. Also, using bundle attribute of the
> Img Tag, I can specify a different bundle other than the default one
loaded
> by
> <init-param>
> <param-name>application</param-name>
> <param-value>MessageResources</param-value>
>  </init-param>
> in the web.xml.
> But when I use this bundle attribute , it gives me following error.
> javax.servlet.jsp.JspException
> java.lang.Throwable(java.lang.String)
> java.lang.Exception(java.lang.String)
> javax.servlet.jsp.JspException(java.lang.String)
> java.lang.String
> org.apache.struts.util.RequestUtils.message(javax.servlet.jsp.PageContext,
> java.lang.String, java.lang.String, java.lang.String, java.lang.Object [])
> java.lang.String
> org.apache.struts.util.RequestUtils.message(javax.servlet.jsp.PageContext,
> java.lang.String, java.lang.String, java.lang.String)
> java.lang.String org.apache.struts.taglib.html.ImgTag.src()
> int org.apache.struts.taglib.html.ImgTag.doEndTag()
> My jsp code looks like
> <html:img  bundle="ImageResources" srcKey="img.i1" />
> If I remove bundle from here & put the img.i1 key in my default
> MessageResources, it works fine. But as mentioned earlier , I want a
> separation between the two kind of resources.
> So , my question is if I am using the bundle attribute of ImgTag correctly
&
> where do I keep my ImageResources File or preferably specify path to it ?
> Thanks in advance of all the answers.
> Shipra Jain
> Web Developer
> GTECH Corporation
>
>