How would you use the JSF DateTimeConverter?
If you are working with dates you probably have had a need to display them in the correct format, or even had to parse them? Well, lets start off with using dateStyle. The example below will use the "long" date style as defined by the server Locale. Valid values are "default", "short", "medium", "long", and "full".
How do you use the JSF NumberConverter?
If you are outputting a value, how would you show a currency code along with it?
See what the JSF Validator API is about!
The definition of a Converter according to the Converter interface:
Introduction to JSF Converters
During the JSF lifecycle each input value needs to be converted. As such the JSF runtime allows you to write converters that will take care of that during request processing.
The following blog articles are part of the JSF Validator series
In the previous blog entry titled "Writing your own validator" you learned how to write a validator and hook it up for validation. At that time we made it all work using the faces-config.xml file. There is however another way, which we will describe below!
Since JSF 2 it is also possible to use BeanValidation as specified in JSR 303. The following blog article describes how this JSR has been integrated within JSF 2.
With the following JSF managed bean.
Writing your own validator is a straightforward process. It involves implementing the Validator API and making sure you register it properly.
Say you want to write a validator that will not allow you to use the string "Hello World" as a value.
Say you want to make sure that a value is required.
If you want to validate input against a regular expression then you would use the RegexValidator.
Say you want to make sure only letters are used for a name.