Pages

Wednesday, January 09, 2013

JSF 2.x Tip of the Day: Displaying Content Conditionally by FacesMessage.Severity

Many times we do, or do not want to display content based on whether there are FacesMessage queued to be displayed. The FacesMessage.Severity can be used to help us determine if messages should be displayed. Please see the table below.

FacesMessage Values
Ordinal Severity
0 INFO
1 WARN
2 ERROR
3 FATAL


The examples below demonstrate a couple of techniques to determine if a component (in this case a <ui:fragment/> containing a <ui:include/>) should be displayed based on whether FacesMessage.Severity are present and if they are not equal to an informational message.

This is equivalent to the listing above.
This displays if the messages are WARN or less.

2 comments :