Java Reference
In-Depth Information
All we need to do is nest a <f:validator> tag inside the input field we wish
to have validated using our custom validator. The value of the validatorId
attribute of <f:validator> must match the value of the value attribute in the
@FacesValidator annotation in our validator.
Now, we are ready to test our custom validator.
While entering an invalid e-mail address into the e-mail address input field and
submitting the form, our custom validator logic was executed and the string we
passed as a parameter to FacesMessage in our validator() method its shown
as the error text by the <h:message> tag for the field.
Facelets templating
One advantage that Facelets has over JSP is its templating mechanism. Templates
allow us to specify page layout in one place. Then, we can have template clients
that use the layout defined in the template. Since most web applications have
consistent layout across pages, using templates makes our applications much more
maintainable because changes to the layout need to be made in a single place. If at
one point we need to change the layout for our pages (for example, add a footer or
move a column from the left side of the page to the right side of the page), we only
need to change the template and the change is reflected in all the template clients.
 
Search WWH ::




Custom Search