0

For what reason facesContext.validationFailed could be null? (in a postBack where there are errors..) I had to resort to an ugly if (#{fn:containsIgnoreCase(facesContext.maximumSeverity,'ERROR')}) showSecurePopup('confirm'); because facesContext.validationFailed is coming back null..

the test code is:

<h:form>
   <h:messages />
   <br></br>

   <h:outputText value="Validation failed: #{facesContext.validationFailed}" />
   <br></br>

   <h:outputLabel for="field1" value="Test Field" />
   <br></br>

   <h:inputText required="true" />

   <h:commandButton action="#{contactBacking.submitComment}" value="Submit"
      <f:ajax render="@form" execute="@form" />
   </h:commandButton>
</h:form>

EDIT: Edited as per @BalusC's answer.. and took screenshot of result:

image

4

1 回答 1

0

FacesContext#isValidationFailed()返回 a booleanwhich is nevernull只需摆脱那个无意义的空检查。

<h:outputText value="Validation failed: #{facesContext.validationFailed}" />
于 2012-07-24T22:38:08.467 回答