检查哪个表格有错误 [英] Check which form has an error
本文介绍了检查哪个表格有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个模式窗口,仅在页面上几种形式之一出错时才要启动.是否可以使用el来识别特定表格是否有错误?
I have a modal window that I only want to launch when one of several forms on a page has errors. Is there a way using el to identify if a specific form has errors?
示例伪代码:
<h:form id="form1">
</h:form>
<h:form id="form2">
</h:form>
<a4j:rendered="#{form1.hasErrors()}">
... modal here ...
</a4j:rendered>
推荐答案
如果ajax请求中包含execute="@form"
,则可以使用 FacesContext#isValidationFailed()
.
If you have an execute="@form"
in the ajax request, then you could use UIForm#isSubmitted()
in combination with 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>
这篇关于检查哪个表格有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文