Search code examples
cssjsf-2icefaces

JSF 2.x hide messages layer when empty


Is there a way the output layer (? if that is the correct term) could be hidden when it is empty such that when info/error messages are written to it, it expands to the height required to fit the messages, vertically stretching the panel that it is contained within? (perhaps using CSS ??)

<h:body>  
  <ace:panel>
...
...
    <h:panelGroup>   
      <h:messages
        infoStyle="color:darkgreen"
        errorStyle="color:darkred">
      </h:messages> 
    </h:panelGroup>   
  </ace:panel>
</h:body>

Solution

  • Provided that all messages are handled by the one and same <h:messages>, you could just check if FacesContext#getMessageList() isn't empty.

    <ace:panel rendered="#{not empty facesContext.messageList}">