我有一个模态窗口,我只想在页面上的几个表单之一出现错误时启动它。有没有办法使用 el 来识别特定表单是否有错误?
示例伪代码:
<h:form id="form1">
</h:form>
<h:form id="form2">
</h:form>
<a4j:rendered="#{form1.hasErrors()}">
... modal here ...
</a4j:rendered>
如果您execute="@form"
在 ajax 请求中有一个,那么您可以UIForm#isSubmitted()
与FacesContext#isValidationFailed()
.
<h:form binding="#{form1}">
</h:form>
<h:form binding="#{form2}">
</h:form>
<a4j:xxx rendered="#{form1.submitted and facesContext.validationFailed}">
Validation of form1 has failed.
</a4j:xxx>
<a4j:xxx rendered="#{form2.submitted and facesContext.validationFailed}">
Validation of form2 has failed.
</a4j:xxx>