The comparison is incorrect. You cannot (reliably) compare strings in your content with ==. When comparing objects with ==it, it only returns trueif they have the same reference , and not a value, as you seem to expect. Objects must be compared with Object#equals().
==. FacesMessage.Severity - . Severity Severity. , sysout , .
:
Iterator<FacesMessage> messages = facesContext.getMessages(clientId);
while (messages.hasNext()) {
FacesMessage message = messages.next();
if (message.getSeverity() == FacesMessage.SEVERITY_ERROR) {
System.out.println("Error: " + message);
}
}