what is the best way to include your own validation messages? I have found the Messages.prop file in the javax.faces jar which contains all the error messages. The messages returned are too robotic so I would like my own for the error checks I need. I'm using Netbeans and can't edit the prop file. Is there a way to include my own prop file that can override the default while still using the keys in the default file that I don't override myself? That sounded long winded so I hope you understand what I am saying I could extract the javax.faces jar and edit the file but I am not sure how to jar it up again without breaking it!
Tim Holloway wrote:Yes, you can add your own custom overrides to the stock JSF message templates. If memory serves, you designate a properties file in the faces-config.xml file.
You can also override both the "required" and "validation failed" messages on a per-control basis like so:
In this particular case, "messages" is a backing bean I presumably constructed from a message bundle.
I copied the default Messages.properties file into my src directory and put it in a package called messages. In the faces-config file I specified it as a message bundle named messages.Messages and it worked. I find it strange though that a property file like this has to be contained in a java package as opposed under the optional JSF resources folder that you can put in WEB-INF. That resources folder is great for css and images.
ps. I didn't know about the validatorMessage attribute, that's handy.
Alan Smith wrote: I find it strange though that a property file like this has to be contained in a java package as opposed under the optional JSF resources folder that you can put in WEB-INF.
You get more flexibility when properties can come from a property service class instead of solely from a fixed-format file. Plus, by placing resources in the classpath, even when they are fixed-format data files, you get the benefit of mechanisms that were created for more than just web environments.