This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Accessing  Message Resource 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 "Accessing  Message Resource" Watch "Accessing  Message Resource" New topic
Author

Accessing Message Resource

Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Hi,

I am looking for a way to access a message property that is maintained in the ApplicationResources.properties file in a Java class that is external to the Struts API.

I would like in a Java Class to be be able to say,

messageResource.get(key, locale) and get back the struts resource for the specified key.

Thanks in advance for any suggestions.


Never be satisfied with anything less than the best and you will surely pass the test...
Durgaprasad Guduguntla
Ranch Hand

Joined: Oct 20, 2003
Posts: 99
You can do this outside struts API by using a ResourceBundle assuming your bundle is located at yourapp/WEB-INF/classes/resources/application_fr.properties. Then you an retrieve the messages from the bundle. The following code snippet would help you:


Thanks,<br />Durgaprasad<br />SCJP1.4, SCWCD1.4, SCBCD1.3,<br />SCEA
Durgaprasad Guduguntla
Ranch Hand

Joined: Oct 20, 2003
Posts: 99
One correction in the above post with code:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing Message Resource
 
Similar Threads
Specifying a message resource file within the Action class
Need Help in accesing the bundle / key value in action class
Message Resource Encoded as UTF-16
Getting values from properties in validate-using multiple message-resources in struts
I want to access the value of keyattribute of message-resource of struts-config.xml in my action