Here is something you may or may not know. JSF Mojarra comes with a small extension tag library with three tags: regular expression validator, credit card validator, and focus setting tag. They are available since JSF version 1.2_09, but maybe even earlier (I didn’t check).
Page setup
Before using any of the tags, add this xml namespace to your Facelet page:
xmlns:mj="http://mojarra.dev.java.net/mojarra_ext"
Regular expression validator
mj:regexpValidator is probably all you need to validate any kind of input by setting the right expression. For example, to validate an email address:
Adding RichFaces into the mix to invoke validation onblur event.
Credit card validator
mj:creditcardValidator uses Luhn Algorithm to validate the input.
Focus
Lastly, mj:focus tags lets you set a focus on any component inside the current form:
... ...
The only thing to remember is to set for attribute to client id, not the component id.
That’s it, enjoy these “secret” tags.
Leave a reply to Axel Cancel reply