IE Primefaces输入密钥提交解决方法

时间:2011-04-10 22:35:03

标签: jsf-2 primefaces

我遇到IE问题,不允许我点击回车键提交表单。我找到了部分解决方案(http://www.thefutureoftheweb.com/blog/submit-a-form-in-ie-with-enter)但我的对话窗口关闭了。我的验证运行并显示错误消息。我如何打开对话框?

<p:dialog id="sgupdlg" header="#{bundle['signUp.HEADER']}" widgetVar="signUpDlg"
        modal="true" styleClass="dialog dialog1" draggable="false"
        resizable="false" showEffect="fade" hideEffect="fade" position="top">
        <h:form id="signUpFrm" binding="#{signUpDetail.signUpFrm}">
        <p:growl id="growl" showDetail="true" showSummary="false" life="3000" errorIcon="/images/Validation-Error.png" infoIcon="/images/Validation-Success.png"/> 

        <p:inputText value="#{signUpDetailBean.firstName}" name="nameInput" required="true" requiredMessage="First Name is Required"/>
        <p:inputText value="#{signUpDetailBean.lastName}" required="true" requiredMessage="Last Name is Required"/> 

        <p:commandButton styleClass="form-btn2"
                        value="#{bundle['signUp.button.LABEL']}" actionListener="#{signUpDetail.signUp}" onclick="trackingSignUpOverlaySave()" 
                        oncomplete="handleSignUpRequest(xhr, status, args)" update="growl"/>
        <p:commandButton type="reset" styleClass="close" />

        </h:form>
    </p:dialog>
    <script type="text/javascript">  


        $ = jQuery
        $(function(){
            $('input').keydown(function(e){
                if (e.keyCode == 13) {
                    $('#signUpFrm').submit();
                    return false;
                }
            });
        });


    </script>  

2 个答案:

答案 0 :(得分:0)

function closeWhenValidationSuccesful(dialog, xhr, status, args) {
    if (!args.validationFailed) {
        dialog.hide();
    } 
}

<p:commandButton value="Save" action="doSomething" update=":formName:panelContainingValidatedElements"
    oncomplete="closeWhenValidationSuccesful(dialogWidgetVar, xhr, status, args)" />

我使用以下命令打开对话框并显示验证错误。您需要将输入移动到panelGrid中,以便可以通过update属性将其作为目标。

答案 1 :(得分:0)

一个简单的标签可以解决它。

oncomplete =“if(args.validationFailed){} else {Professor.show(),Student.hide();}”

您希望将此应用于教授小部件var