This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Struts and the fly likes How to do share message-resources? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to do share message-resources?" Watch "How to do share message-resources?" New topic
Author

How to do share message-resources?

yun liu
Greenhorn

Joined: Apr 11, 2005
Posts: 6
We assumed that if we used messages or errors
(bean:message and html:errors) within a model and the message was not
found in the message resources for that model, that Struts would look to
the default app for the messages. We did not like the idea of duplicating
messages across all model. For example, most all of our modules will be
using messages for our buttons like Save, New, Cancel, Delete, etc. (we are
using i18n so it's not feasible to hard-code these). We wanted to define
these once in the message resources for the default app and override the
message in the model as necessary.
How to do this,Please give me some advise.
I used Struts1.2.

Thanks advance
david.liu
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
There is no concept of inheritance with modules. Each module is it's own separate entity, and the configuration at the root module is not propagated to the other modules.

You can, however, specify more than one resource bundle per module. So you could create a resource bundle that contains messages common to all modules and include that bundle in each module along with the bundle unique to that module. The down side of this method, though, is that once you have more than one resource bundle, you must specify which one you're using with every <bean:message> tag.

Here's an example of the struts-config.xml file:

<message-resources key="base" parameter="com.mycompany.ApplicationResources"/>
<message-resources key="module" parameter="com.mycompany.module.ApplicationResources"/>

Then, when you use the <bean:message> tag, you must specify bundle="base" or bundle="module"


Merrill
Consultant, Sima Solutions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to do share message-resources?
 
Similar Threads
Using JMS in websphere
How to make changes runtime in ApplicationResources.prop without restarting server
How to make changes runtime in ApplicationResources.prop without restarting server
Overriding Message Bundles in JSF 2.x
Send a message from EJB to Servlet without JMS.