关闭Jquery对话框之前未显示JSF验证错误 [英] JSF Validation error is not displaying before close Jquery dialog
本文介绍了关闭Jquery对话框之前未显示JSF验证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Jquery对话框来获取用户输入.
I have a Jquery dialog to get user input.
<div id="icPopup">
<td>
<h:selectOneMenu id="selectICType" value="#{sessionBean.icStartLetter}" required="true" requiredMessage="Select IC type" style="width:100px;">
<f:selectItem itemValue="" itemLabel="- Select -"/>
<f:selectItems value="#{sessionBean.icStartLetterTypes}"/>
</h:selectOneMenu>
</td>
<td align="center">
<h:inputText id="icNumber" value="#{sessionBean.icNumber}"></h:inputText>
</td>
<td>
<div id="mainBtnGrey" class="mainBtnLeftAlign">
<h:commandLink action="#{home.checkICForError}" value="Confirm"/>
</div>
</td>
</div>
我的脚本代码是
$('#mainBtnGrey').click(function (e) {
e.preventDefault();
$('#icPopup').dialog('close');
});
这里的问题是,在显示验证错误之前,请关闭对话框.如果Bean返回验证错误,如何保持打开对话框?
The issue here is, before display the validation errors the dialog is closed. How to keep open the dialog if the bean return the validation errors?
推荐答案
如果您的脚本代码位于<script/>
内的XHTML页面上,则可以使用以下命令检查EL的验证状态:
If your script code is present on the XHTML page within <script/>
, you could just check the validation status of the EL using:
$('#mainBtnGrey').click(function (e) {
e.preventDefault();
if(!#{facesContext.validationFailed})
$('#icPopup').dialog('close');
});
facesContext.validationFailed
将检查整个JSF请求的验证状态是否失败.
facesContext.validationFailed
will check the validation status of the entire JSF request for failure.
这篇关于关闭Jquery对话框之前未显示JSF验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文