Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p><em>how to display faces message to the specify control? It keep showing me error: there are some unhandled FacesMessages, this means not every FacesMessage had a chance to be rendered</em></p> </blockquote> <p>You need to specify a valid client ID. The client ID is not the same as component ID. The client ID is whatever you see in the JSF-generated HTML output. Also, the client ID should be the one of the input component, not of the message component.</p> <p>So, given a </p> <pre><code>&lt;h:form id="particular"&gt; &lt;p:inputText id="name1" /&gt; &lt;p:message id="msg1" for="name1" /&gt; &lt;/h:form&gt; </code></pre> <p>the input component has the client ID <code>particular:name1</code> (rightclick page in browser and do <em>View Source</em> to see it yourself). So, the message should be attached on exactly this client ID.</p> <pre><code>context.addMessage("particular:name1", message); </code></pre> <hr> <blockquote> <p><em>if I press the submit button by empty all the three inputText field, it will show me the "required input error message" in each of the control message, but how to show the "there are 3 error in the page" error in the global message(id="msg") ?</em></p> </blockquote> <p>The <code>&lt;p:message&gt;</code> is not the valid component for that, you should use <code>&lt;p:messages&gt;</code>.</p> <pre><code>&lt;p:messages id="msg" globalOnly="true" display="text"/&gt; </code></pre> <p>The <code>globalOnly="true"</code> attribute means that only messages with a <code>null</code> client ID will be shown. So, you should just add exactly such a message.</p> <pre><code>context.addMessage(null, message); </code></pre> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/2930535/how-to-use-jsf-hmessages-better">How to use JSF h:messages better?</a></li> <li><a href="https://stackoverflow.com/questions/28351976/when-and-how-is-clientid-generated-in-jsf">When and how is clientID generated in JSF?</a></li> </ul> <hr> <p><strong>Unrelated</strong> to the concrete problem, the non-global messages ("Invalid name") which you're trying to add there should actually be done by a fullworthy validator. See also <a href="https://stackoverflow.com/questions/6047866/how-to-perform-validation-in-jsf-how-to-create-a-custom-validator-in-jsf/6047913#6047913">How to perform validation in JSF, how to create a custom validator in JSF</a> for a concrete example.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload