The
tag shows all the error messages at one place corresponding to UI elements. The “
for
” attribute can be used to represent the field for which error message has to be displayed.
In this section, we will see how to use the default JSF
validators to shoot out the built in error messages to the users.
Some of the points to keep in mind before we write the xhtml file are :
The h:message
tag is used to display all the error messages related to the UI
components.
This h:message
has the following attributes
* id
attribute is the unique identifier for a ui component.
* style
displays the style information like color,font etc
* for
attribute describes the component name applicable for the form.
Let’s look in detail with an example as how to display the error messages
Create a JSF page named error.xhtml
as error.xhtml
<h:message for="cname" style="color: red"></h:message>