I keep this page connected to my brain while I spend days and nights playing with JBoss Seam.

Message Rendering

Before there was Seam, the only way to conditionally display messages with JSF was to check for the maximum severity using the FacesContext.

<h:panelGroup rendered="#{not empty facesContext.maximumSeverity}">
  <h:messages globalOnly="true" />
</h:panelGroup>

Seam introduces a component named facesMessages that provides more insight into the stack of registered FacesMessage objects. If you goal is to simply display global messages (those not associated with a clientId, aka form element), Seam gives you an accessor for those messages.

<!-- feed them to the JSF compoent -->
<h:panelGroup rendered="#{not empty facesMessages.currentGlobalMessages}">
  <div id="messages"><h:messages globalOnly="true" /></div>
</h:panelGroup>

<!-- iterate of them yourself -->
<h:panelGroup rendered="#{not empty facesMessages.currentGlobalMessages}">
  <ul id="messages">
    <li jsfc="ui:repeat" var="message" value="" class="#{message.severity}">#{message.summary}</li>
  </ul>
</h:panelGroup>

Now, if you just want all the messages, and you would like to iterate over them yourself, Seam gives you access to those as well.

<h:panelGroup rendered="#{not empty facesMessages.currentMessages}">
  <ul id="messages">
    <li jsfc="ui:repeat" var="message" value="" class="#{message.severity}">#{message.summary}</li>
  </ul>
</h:panelGroup>

What Seam does not yet fix in JSF is a means to access messages that aren’t global :-(