检查哪个表单有错误

Dav*_*ple 1 jsf jsf-2

我有一个模态窗口,我只想在页面上的几个表单中的一个有错误时启动.有没有办法使用el来识别特定表单是否有错误?

示例伪代码:

<h:form id="form1">

</h:form>

<h:form id="form2">

</h:form>

<a4j:rendered="#{form1.hasErrors()}">
    ... modal here ... 
</a4j:rendered>
Run Code Online (Sandbox Code Playgroud)

Bal*_*usC 6

如果你有一个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>
Run Code Online (Sandbox Code Playgroud)