1

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?

1 Answers1

4

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, or null 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.

skuntsel
  • 11,624
  • 11
  • 44
  • 67
  • 1
    In other words, it's thus very definitely **not** some ID of the enduser (client) who's visiting the website as the OP seemed to think. – BalusC Nov 29 '13 at 20:56
  • @BalusC The second part of the question is disastrously badly written so I decided not to touch it at all (probably should've linked to some of the opus answers of yours, but that's terrifyingly slow on a cell phone so I hope OP's going to do that on his own). As to your comment, OP could have also probably confused that with `jsessionid` that "identifies a client". – skuntsel Nov 29 '13 at 21:03