This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Message resources and struts modules" Watch "Message resources and struts modules" New topic
Author

Message resources and struts modules

Jeremy Tukif
Greenhorn

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,

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

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

Anyone have a solution to this?
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
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: 2053
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)



usage



tag lib section


Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
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