title: JSF using EL to test global messages presence
body: <p>I'm trying to display a block only if there are Global messages in the JSF Queue.</p>
  
  <p>I tried to use <code>rendered="#{not empty facesContext.getMessageList(null)}"</code>, but it's always evaluated to false.</p>
  
  <p>Only way I found is to create a custom EL function and test it in java.</p>
  
  <p>eg. :
  my el function :</p>
  
  <pre><code>public static boolean isFacesGlobalMessages() {
    return ! FacesContext.getCurrentInstance().getMessageList(null).isEmpty();
  }
  </code></pre>
  
  <p>JSF page :</p>
  
  <pre><code>&lt;h:panelGroup class="block1" layout="block" rendered="#{el:isFacesGlobalMessages()}"&gt;
    &lt;div class="block-warn-body"&gt;
      &lt;rich:messages id="msg" globalOnly="true"/&gt;
    &lt;/div&gt;
  &lt;/h:panelGroup&gt;
  </code></pre>
  
  <p>I'm using Mojarra 2.1.5.</p>
  
  <p>Am I missing something ?
  Thanks !</p>
  
  <p>Edit : tried the following suggestions, but no luck so far :</p>
  
  <ul>
  <li><code>#{not empty facesContext.getMessageList(null)}</code> -> always false</li>
  <li><code>#{! facesContext.getMessageList(null)}</code> -> error</li>
  <li><code>#{! empty facesContext.getMessageList(null)}</code> ->  always false</li>
  <li><code>#{fn:length(facesContext.getMessageList(null)) &gt; 0}</code> ->  always false</li>
  <li><code>#{not empty facesContext.messageList(null)}</code> -> Error : Method messageList not found</li>
  <li><code>#{not empty facesContext.messageList}</code> -> returns true if it's a validation  error (I only want true on global error)</li>
  <li><code>#{! facesContext.getMessageList(null).isEmpty()}</code> -> throws IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class java.util.Collections$UnmodifiableCollection with modifiers "public"</li>
  </ul>