Thanks Hubert.
I'll give this a try.
One last question. To follow up on Anne's comments, are you using a common
request processor across modules?
Do you aggree with Anne that having unique request processors per module,
the ResourceBundles cannot be accessed cross modules?
Josh Holtzman
American Data Company
jholtzman@americandatacompany.com
Voice: (310) 470-1257
Fax: (310) 362-8454
Sun Microsystems iForce Partner
-----Original Message-----
From: Hubert Rabago [mailto:jakartauser@yahoo.com]
Sent: Tuesday, April 27, 2004 11:59 AM
To: Struts Users Mailing List
Subject: RE: REPOST: Accessing MessageResource Objects from across Applica
tion Modules.
I use these methods and they work for me in getting either the default
resource bundle or one specified by a bundle key, from within the default
module or within a non-default module:
/**
* <p>Return the default message resources for the current module.</p>
*
* @param request The servlet request we are processing
*/
protected MessageResources getResources(HttpServletRequest request) {
return ((MessageResources)
request.getAttribute(Globals.MESSAGES_KEY));
}
/**
* <p>Return the specified message resources for the current module.</p>
*
* @param bundle The key specified in the
* <code><message-resources></code> element for the
* requested bundle
* @param request The servlet request we are processing
* @param servletContext the current {@link ServletContext}
*/
protected MessageResources getResources(String bundle,
HttpServletRequest request,
ServletContext servletContext) {
// Identify the current module
ModuleConfig moduleConfig =
RequestUtils.getModuleConfig(request, servletContext);
// Return the requested message resources instance
return ((MessageResources) servletContext.getAttribute
(bundle + moduleConfig.getPrefix()));
}
--- Josh Holtzman <jholtzman@americandatacompany.com> wrote:
> Hubert,
>
> I have not attempted to declare the same resource file in each module
> config file. I will try and do that but I don't think it will make a
> difference.
>
> I have pages in my "/extranet" module that successfully use the Struts
> html image tag to retrieve values from my "/extranet" resource bundle.
> For example the following tag works just fine:
>
> <html:img srcKey="global.common.logo.src" altKey="global.common.logo.alt"
> bundle="<%=bundle%>"/>
>
> Where bundle="MESSAGES_EXTRANET/extranet".
>
> This leads me to believe it is not an issue in the config file, but
> I'll surely test out your suggestion.
>
> Thanks again for all the help.
>
>
>
> Josh Holtzman
>
> American Data Company
>
> jholtzman@americandatacompany.com
>
> Voice: (310) 470-1257
>
> Fax: (310) 362-8454
>
>
>
> Sun Microsystems iForce Partner
>
>
> -----Original Message-----
> From: Hubert Rabago [mailto:jakartauser@yahoo.com]
> Sent: Tuesday, April 27, 2004 8:54 AM
> To: Struts Users Mailing List
> Subject: RE: REPOST: Accessing MessageResource Objects from across
> Applica tion Modules.
>
> It's true that message resources are per module. Have you tried just
> declaring that same resource in the struts-config of the modules
> needing that resource?
> In both your main struts-config.xml and struts-config-something.xml,
> try using the same <message-resources> entry.
>
>
> --- "Liu, Anne I" <anne.liu@twc.state.tx.us> wrote:
> > I'm not positive, but I think MessageResources are per module. Thus
> > you will need to either include the message-resources element in
> > your module's struts-config or include the struts-config.xml in your
> > module's configuration on the web.xml (this will cause all the
> > resources to be duplicated in your new module... may want to
> > consider just breaking out the common components into another config
> > file)
> >
> > <init-param>
> > <param-name>config/examples</param-name>
> >
> >
>
<param-value>/WEB-INF/xml/struts-config.xml,/WEB-INF/xml/struts-config-examp
> > les.xml</param-value>
> > </init-param>
> >
> >
> > Either case, you would access it in the request using the
> > MESSAGE_KEY/module_name.
> >
> > Hope this helps!
> >
> > > -----Original Message-----
> > > From: Josh Holtzman [SMTP:jholtzman@americandatacompany.com]
> > > Sent: Monday, April 26, 2004 7:11 PM
> > > To: 'Struts Users Mailing List'
> > > Subject: REPOST: Accessing MessageResource Objects from across
> > > Application Modules.
> > >
> > > I haven't received any response on this one, and just wanted to
> > > make sure it wasn't overlooked.
> > >
> > > I'm beginning to run into a time crunch and once again would
> > > appreciate any assistance.
> > >
> > > Thanks again friends.
> > >
> > > __________________________________________________________________
> > > __
> > > ___
> > >
> > > Hello,
> > >
> > > I've been scouring through the archives for some direction on this
> > > but
> > can
> > > not seem to find an answer.
> > >
> > > Any suggestions are greatly appreciated.
> > >
> > > I have a custom JSP Tag that within the source code accesses the
> > > MessageResource object with the following line of code.
> > >
> > > MessageResources messages = (MessageResources)
> > > request.getAttribute( org.apache.struts.Globals.MESSAGES_KEY );
> > >
> > > When I use this tag from within the default Struts application
> > > module
> > this
> > > code successfully retrieves the default MessageResources object.
> > >
> > > I have created an additional application module called "/extranet".
> > > When I use this custom tag within the /extranet module, the
> > > MessageResource lookup stated above returns null. If I understand
> > > the javadocs correctly, it states that the default Message
> > > resources are stored with the Globals.MESSAGES_KEY and the
> > > concatenation of the name of the application module the
MessageResources are located.
> > > In my case I want to retrieve the MessageResources from the
> > > default application, so, I haven't appended anything to the end of the
key.
> > > I have also tried appending "/" and "/extranet" to the end of the
> > > key when I perform the lookup, and I still receive null.
> > >
> > > Once again, and light you can shed on how to correct this would be
> > > of significant assistance.
> > >
> > > Best regards to all.
> > >
> > > Josh Holtzman
> > >
> > > American Data Company
> > >
> > > jholtzman@americandatacompany.com
> > >
> > > Voice: (310) 470-1257
> > >
> > > Fax: (310) 362-8454
> > >
> > >
> > >
> > > Sun Microsystems iForce Partner
> > >
> > >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Win a $20,000 Career Makeover at Yahoo! HotJobs
> http://hotjobs.sweepstakes.yahoo.com/careermakeover
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
|