title: JSF FacesContext#addMessage is not displayed
body: <p>In my <a href="https://stackoverflow.com/questions/10367152/jsf-authentication-cannot-intercept-error-messages">previous question</a>  I had the problem of displaying validation messages from a Login form. That issue is now solved, but this time I am not able to display a custom message with <code>FacesContex#addMessage</code>.</p>
  
  <p>Using JSF + PrimeFaces.</p>
  
  <pre><code>&lt;p:dialog header="Login" widgetVar="loginDlg"&gt;
      &lt;h:form id="loginForm"&gt;
          &lt;h:panelGrid columns="3" cellpadding="5"&gt;
              &lt;h:outputLabel for="username" value="Username:" /&gt;
              &lt;p:inputText value="#{loginBean.username}" id="username" required="true" label="username" /&gt;
              &lt;p:message for="username" /&gt;
              &lt;h:outputLabel for="password" value="Password:" /&gt;
              &lt;h:inputSecret value="#{loginBean.password}" id="password" required="true" label="password" /&gt;
              &lt;p:message for="password" /&gt;
              &lt;f:facet name="footer"&gt;
                  &lt;p:commandButton value="Login" id="loginDlgButton" update=":loginForm,:welcomeMsg" actionListener="#{loginBean.login}"
                                      oncomplete="handleLoginRequest(xhr, status, args)"/&gt;
                  &lt;p:message for="loginDlgButton" /&gt;
              &lt;/f:facet&gt;
          &lt;/h:panelGrid&gt;
      &lt;/h:form&gt;
  &lt;/p:dialog&gt;
  </code></pre>
  
  <p>In <strong>LoginBean</strong> (a <code>SessionScoped</code> <code>ManagedBean</code>):</p>
  
  <pre><code>public void login() {
      FacesContext context = FacesContext.getCurrentInstance(); 
      RequestContext rContext = RequestContext.getCurrentInstance();
      HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); 
      try { 
          request.login(this.username, this.password); 
          rContext.addCallbackParam("loggedIn", true);
      } catch (ServletException e) { 
          rContext.addCallbackParam("loggedIn", false);
          context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Login Error", "Invalid credentials")); 
      } 
  }
  </code></pre>
  
  <p>This code, when validation succeeds and login fails, should display the "Invalid credential" message, but doesn't. Moreover, somewhere in the body of my web page, I have also added this line:</p>
  
  <pre><code>&lt;p:messages autoUpdate="true" /&gt;
  </code></pre>
  
  <p>but my message isn't displayed even there.</p>
  
  <p><a href="http://docs.oracle.com/cd/E17802_01/j2ee/javaee/javaserverfaces/2.0/docs/api/javax/faces/context/FacesContext.html#addMessage%28java.lang.String,%20javax.faces.application.FacesMessage%29" rel="nofollow noreferrer">Javadocs</a> say that</p>
  
  <blockquote>
    <p>If clientId is null, this FacesMessage is assumed to not be associated with any specific component instance</p>
  </blockquote>
  
  <p>But I can't understand what this means.</p>