Can you explain me why we need in String clientId
in the method
void addMessage(String ClientId, FacesMessage msg);
?
Is it true that when client sent an initial request to server then server assign to this client a specific String ClientId
. As i understand FacesContext
created when aplication deployed and runnig the first time and this FacesContext
is unique for application. Is it true?
Client id in
FacesContext#addMessage(String clientId, FacesMessage message)
is needed to be able to add a specific message to a specific component. You can either specify a client id of the component you'd like to assign the message to, ornull
to add the message to the messages stack not tied to a specific component. The latter will be updated in e.g.<h:message for="clientId>
, while the latter in e.g.<h:messages globalonly="true">
. You can add a message to global messages in case it is not component-specific, for instance, when database operation failed.