How to create new message properties file in JSF to add adeqate error messages

I am new to JSF. I don’t understand how to create my own message properties files and where exactly to place this file. Can anyone help me with this?

+2
source share
1 answer

I do not get how to create a new own properties file

Create a text file according to the java.util.Properties contract. ISO-8859-1 encoded text with key=value pairs, each in its own line. In the case of a JSF message resource, you can use key names as described in the JSF specification to override the default messages. You can find them in chapter 2.5.2.4 of the JSF specification (here the JSF 1.2 specification and the JSF 2.0 specification ).

and where to put this file under the directory

Just put it in the classpath, as with regular Java classes.

The <message-bundle> file in faces-config.xml must reference the fully qualified name of the resource resource. If you named the properties file Messages.properties and simply dropped it into the root directory of the path, then its declaration should look like

 <application> <message-bundle>Messages</message-bundle> </application> 

But if you drop it, for example, into the com.example.i18n package, it should look like this:

 <application> <message-bundle>com.example.i18n.Messages</message-bundle> </application> 
+7
source

All Articles