I would like to display different FacesMessages with programmatically set clientIds. In my view I used
<h:outputText value="warnMessages #{facesContext.getMessageList('warnMessages')}" />
<h:outputText value="validationMessages #{facesContext.getMessageList('validationMessages')}" />
for debugging. The messages are all there. But...
<h:messages for="warnMessages" />
<h:message for="warnMessages" />
doesn't display anything. Only
<h:messages />
works. But I would like to have different message-boxes displayed together. How can I do that? Thanks
Marcel
It look like that you're abusing client IDs to separate custom/global messages from normal validation messages.
You shouldn't do that. If you want to display a custom/global message, just don't specify any client ID. I.e., set it to null.
context.addMessage(null, facesMessage);
This way they will all appear in
<h:messages globalOnly="true" />
And use the renmant of the messages the usual way.
<h:inputText id="foo" required="true" />
<h:message for="foo" />
or
<h:messages globalOnly="false" />
The h:messages display all messages, also those with missing client id. So the for attribute is not allowed.
The for attribute in h:message must match the id attribute of another component: in your example you have to set id="warnMessages" in whatever h:inputText you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With