• 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Multiple Property Files in Struts

Posts: 1
Netbeans IDE PHP Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,

We (the company I am working in) are trying to separate our framework from our applications. I was given the task to work out a solution how to separate the .properties file of the application and the ones for our framework.
Currently we are storing all of our text in one .properties file. I've already worked out a basic solution (which I unfortunately cannot show here, private business stuff you know) but as we are using JSP pages and ActionMessages to display errors and stuff and our simple intern method quickly blows up the code of displaying a simple message, I'd like to work out a solution that requires almost no chances to our current code.

What I've got so far:
In struts-config.xml, you declare the following line to include your .properties file.

But you cannot simply put two of these lines into the config (like the following) because it would overwrite the previous:

After a little more research, I've found out that you can put a key in this tags so they can be distinguished.

The problem here is: You have to know, where the message key is located and that is something that we should not have to care about in our code.
And as far as I have seen, there is no fast (meaning one-liner) way of getting the value of a message key in Java code. So something like the following does not work:

As I've said, we have a method somewhere to put in the correct values and I also know that you can add a normal string to an ActionMessage by using the boolean parameter in the Constructor.

But I (or we) want to avoid this.

I should add that I am new to Java / JSP development. I'm working with it for about 2 months know and before I did C# / .NET development so there is a lot of stuff I don't know about.
If someone knows a solution, thank you in advance.
Posts: 9559
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch.
Our Ant build file concatenates multiple properties files to the single file Struts uses.
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!