0
votes

PrimeFaces/JSF 2.0

When you use p:message.... and say your outputText has required="true", you see the error icon in the message displayed to the right of the field if the user leaves the field blank.

<!--  NAME -->
  <p:panelGrid styleClass="noBorders" columns="2" columnClasses="inputText" style="width:600px">
   <h:inputText id="Name" size="60" maxlength="70" required="true" styleClass="#{not     component.valid ? 'ui-input-invalid' : ''}" style="width: 300px" value="#{tinRequestBean.name}" >
    <f:validator validatorId="gov.irs.eservices.tm.validations.NameValidator" />
   </h:inputText> 
   <p:message for="Name" display="default" style="color: red" />
  </p:panelGrid>

However, if you use a Validator to check the contents of the field in some way, the standard FacesMessage, even with FacesMessage.SEVERITY_ERROR, the error icon does not show up.

  if (msgStr.length() > 0) {
   FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "TIN: Validation error: "   msgStr, null);
   throw new ValidatorException(msg);
  }

Does anyone know a way to create a FacesMessage with an icon attached? It's certainly not in the constructor.

1
This is not a standard JSF feature. This is a PrimeFaces feature. The icon is not definied in standard JSF FacesMessage API. The icon is definied in CSS associated with <p:message> which changes conditionally based on message severity. As to the concrete problem, are you absolutely sure that the message is been presented by <p:message(s)> and not <h:message(s)>? - BalusC

1 Answers

0
votes

Set the display="both" on the <p:message/>(or just leave that attribute out altogether, both is the default). This will display both the text and the icon. As far as I can tell, default is not a valid option