• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Struts Message Resource

 
Author
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does Struts 1.0.* version provide for having multiple message resources?

Also, how do you refer to the key values in different resource files? Do these keys have to be unique across all the properties files that are being used as message resources?
So that i could use something like <bean:message key="key"/> in my jsp.
Message resources seems rather confusing, in earlier examples, the properties file is passed as an init param to the action servlet. However, in newer examples, the file name pops up in the message-resources tag in struts-config.xml
Would sincerely appreciate any help in this regard. My primary interest is having multiple *.properties files as resources and accesing them in my JSP using key values for bean:message tag.
thanks
harshad
 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am moving this to the Java Frameworks forum.
 
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure about Struts 1.1beta2 but in 1.0.2, you just create translations of your english properties file and follow the ResourceBundle convention of naming those files.
e.g.
ApplicationResources.properties
ApplicationResources_de.properties
ApplicationResources_fr.properties
And assuming that the files can be found under the classpath at path org.apache.struts.webapp.example; the web.xml looks like this:

<init-param>
<param-name>application</param-name>
<param-value>org.apache.struts.webapp.example.ApplicationResources</param-value>
</init-param>
So in your web page, you need to pass not only the "key" but the "locale" like this:
<bean:message key=".." locale=".."> You do not need to do this if you've set your locale in the config.
Pho
 
Harshad Oak
Author
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Pho
My purpose is not really to achieve internationalization. The messages that we have are all in English. Just that we have kept messages dealing with different issues in different *.properties files.
I could use the internationlization way you have suggested to achieve this. However, that i don't think will be proper in this case.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!