Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The components <code>&lt;h:message&gt;</code> and <code>&lt;h:messages&gt;</code> are dedicated to display messages to users (generally error message).</p> <p>For example, when you have a validation on a field that failed (for example the user didn't fill a required field, or inputed a string in a number-only field), then a <code>FacesMessage</code> is added to the <code>FacesContext</code> object. The <code>&lt;h:message&gt;</code> and <code>&lt;h:messages&gt;</code> are then used to display the message in the page.</p> <p>The component <code>&lt;h:messages&gt;</code> will display all the messages contained in the <code>FacesContext</code>, while the <code>&lt;h:message&gt;</code> is dedicated to a specific clientId (a specific field). The latter is usefull when you want to place the message close to a field for example.</p> <p>Note that you can add any kind of message that will displayed to the user:</p> <pre><code>FacesContext.getInstance().addMessage(null, new FacesMessage("The message to display")); </code></pre> <p>In this example, the first parameter is the ID field of the field that is concerned by this message (usefull when the message is a validation message for a specific field). <code>null</code> means that the message is a general information (i.e. not linked to any particular field).</p> <p>You can see an example of this component <a href="http://livedemo.exadel.com/richfaces-demo/richfaces/messages.jsf" rel="noreferrer">here</a>. Note that this example uses the <code>rich:messages</code> that is an extension (provided by RichFaces) of the "basic" <code>&lt;h:message/&gt;</code>, but the principle is the same.</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