aspose file tools*
The moose likes Struts and the fly likes Getting messages.properties dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Getting messages.properties dynamically" Watch "Getting messages.properties dynamically" New topic
Author

Getting messages.properties dynamically

Fawad Ali
Ranch Hand

Joined: Dec 28, 2009
Posts: 112
Hi All,
I want to get the properties files dynamically for internationalization based on some conditions. How can I do that? Let me explain the scenario a bit. I have an application running different events. Each event has its own properties file for Spanish, Italian languages etc. If I place the properties files in /Events/{eventName}/messages.properties, then, is there any way in Struts to get the required properties file for a specific event dynamically at run time.

Thanks in advance.


Regards, Fawad Ali.
Software Engineer, Stafona Inc. - My Blog
Fawad Ali
Ranch Hand

Joined: Dec 28, 2009
Posts: 112
To explain more precisely. I have two events eventA and eventB. Both have different property files. If I want to visit an action named abc.action with eventA then the Struts tags should take the key, value pair for internationalization from a file at /Events/eventA/messages_fr.properties. If I want to visi the same action (abc.action) with eventB, then the properties file should be read from /Events/eventB/messages_fr.properties.

Basically I want to overwrite the Struts default path for Internationalization which is resources folder right now. Is it possible with Struts and struts tags or not?

BTW, I am using Struts 2.0.
Fawad Ali
Ranch Hand

Joined: Dec 28, 2009
Posts: 112
Hi:
Still no reply from anyone . I have, although, looked a bit into the tags and found that can be used to load a customProperties.properties file for internationalization. This is fine but I want the customProperties file name to be dynamic from action class. I am trying to do the following



But it wont load the properties file whose name is stored in the resourceBundle variable in the action class. Any idea how can I set the fileName from action class to this tag?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting messages.properties dynamically
 
Similar Threads
Receiving error while starting application
Unable to get data from global resource using key attribute
Customized error messages for validateLength
ResourceBundle
Resourcebundle can not be found!