jQuery in Action, 2nd edition*
The moose likes Struts and the fly likes Message resources and struts modules Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Message resources and struts modules" Watch "Message resources and struts modules" New topic

Message resources and struts modules

Jeremy Tukif

Joined: Sep 28, 2005
Posts: 2
Hi all,

I have an application with several modules.
In one of these modules, I defined the two following message resources:
<message-resources key="context" null="false" parameter="blabla.context.ApplicationResources"/>
<message-resources key="menu" null="false" parameter="blabla.menu.ApplicationResources"/>.

And in my JSP, I have:
<bean:message bundle="context" key="myLocale"/>
=> When I want to display the page, I get the following error: "Cannot find message resources under key 'context'"

However, if I add the module context path, it works:
<bean:message bundle="context/path_to_my_module" key="myLocale"/>.
I'm quite surprised that struts does not add this "path_to_my_module" by itself..., and I don't like the idea to "hardcode" my module path in each <bean:message> bundle property...

Thanks in advance,

[ September 29, 2005: Message edited by: Jeremy Tukif ]
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2049
I also need to resolve this.

Anyone have a solution to this?
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2049
I digged into the pageContext. I found this below which I will use as a workaround now.

In summary, the module prefix is in the request context.

Example: if your module name is APPLE, the above will return /APPLE

that is, with a slash.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2049
I created a custom tag. (geez, i am hoping i researched enough that there is no existing tag like this....or im wasting my time)


tag lib section

Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2049
A couple of weaknesses for the above solution is if you happen to use for some reason, iframe and window.open to open a jsp directly without passing through struts, as the request context wouldnt contain the struts attribute we need.
I agree. Here's the link: http://aspose.com/file-tools
subject: Message resources and struts modules
Similar Threads
multiple message resource file for multiple struts-config.xml
Multiple properties files
Struts Modules and message resources
How to do share message-resources?
serveral ApplicationResources .properties for one project?