JSF Validation error is not displaying before close Jquery dialog

ぃ、小莉子 提交于 2019-12-24 12:26:03

问题


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>

And my script code is

$('#mainBtnGrey').click(function (e) {
    e.preventDefault();
    $('#icPopup').dialog('close');
});

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?


回答1:


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 will check the validation status of the entire JSF request for failure.



来源:https://stackoverflow.com/questions/27224338/jsf-validation-error-is-not-displaying-before-close-jquery-dialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!