making web application programming easier is possible


manage properties files

As we saw in "HOW TO : WEBAPP > jfw.properties" the framework comes with a properties file which must be configured, to work properly. The class used for managing this file is PropertiesManager.
This class offers some methods for reading the parameters defined in a properties file. The parameters of the properties files are normally called keys. To get an instance of PropertiesManager we can use the constructor of this class for creating a new instance, but it's much better to use the class PropertiesProxy. Here is an example:

In the above example we get a PropertiesManager for the file jfw.properties.

The PropertiesProxy cache the PropertiesManager already instantiated, so a second call for getting an instance for the same properties file will return the instance of the PropertiesManager found in cache.

As you can see, the name of the file (String name = ...) is without the suffix ".properties".

Since the jfw.properties has no locale specific values, for indicating the default locale, we pass null in the language parameter. The possible values for the language parameter is defined here (ISO 639-1).

For reading the keys defined in the property file we can use something like this:

Remember that the properties files must be saved in a directory or in a jar file declared in classpath. The "WEB-INF/classes/" directory, for example, is a directory of the classpath.