Faces messages
The JSF provides two custom tags to display error messages. The <h:message>
tag displays messages that are bound to specific components. The <h:messages>
tag displays messages that are not bound to specific components.
We saw our first use of <h:message>
in Chapter 3, Building JSF Forms. The tag is typically associated with a form control. We can add messages to our JSF pages with the following:
<h:messages globalOnly="false" styleClass="alert alert-danger" />
The tag is added to the top of the content. The attribute globalStyle
is a Boolean value, and it specifies whether the tag should display messages that are not associated with a component. Here, we are using the Bootstrap CSS selectors again.
The following is a table of the attributes that are shared between the JSF tags, <h:messages>
and <h:message>
:
Attribute |
Description |
---|---|
|
Specifies the unique identifier |
|
Specifies the CSS class selectors for error messages |
|