facesContext.validationFailed是什么原因可能为null? (在有错误的postBack中..)
我不得不求助于一个丑陋的if (#{fn:containsIgnoreCase(facesContext.maximumSeverity,'ERROR')}) showSecurePopup('confirm');
,因为facesContext.validationFailed将返回null ..
测试代码是:
<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>
编辑:根据@ BalusC的回答编辑..并截取结果截图:
答案 0 :(得分:0)
FacesContext#isValidationFailed()
返回boolean
从不 null
。只是摆脱那种无意义的无效检查。
<h:outputText value="Validation failed: #{facesContext.validationFailed}" />