ioreskovic
ioreskovic

Reputation: 5699

What is the preferred way to read and write to a .properties file from within a Tapestry application

What is the preferred way to read and write to a .properties file from within a Tapestry application?

I have a Tapestry web application and at some point, I need to read (and write only once) some properties from a .properties file.

The application is deployed on a Glassfish server (3.1.2.2).

Where is the best location to write such a file and is there a preferred way on how to do it? It would be nice if it would be packed somewhere where the admins could access it without much troubles?

Ty in advance :)

Upvotes: 0

Views: 469

Answers (3)

BugiLesPaul
BugiLesPaul

Reputation: 88

Although this approach is best suited for localization, you can use messages for your problem. First, create new .properties file in the same folder where your pages (.tml) are, or add them as a resource bundle. Also, name the .properties file same as the page. Then, you can inject the properties in your code like this:

@Inject
private Messages messages;

Then you can use built in methods .get() and .format() to read and write to properties. Visit these to links to find more information about this: http://tapestry.apache.org/localization.html http://tapestry.apache.org/5.3.7/apidocs/org/apache/tapestry5/ioc/Messages.html

Upvotes: 0

Tawus
Tawus

Reputation: 504

We use Apache Commons Configuration and it works really well for us. It is very easy to configure as a service/Injectable Object and you can always use BeanEditForm for editing such a configuration.

Upvotes: 1

Jorge_B
Jorge_B

Reputation: 9872

Do you need to query and edit your own application configuration options? Have you thought about persisting it into a data base and discarded the idea for some particular reason? Maybe it would be a more consistent idea

Upvotes: 1

Related Questions