【问题标题】:IE Primefaces Enter Key Submit WorkaroundIE Primefaces 输入密钥提交解决方法
【发布时间】:2011-04-10 22:35:02
【问题描述】:

我遇到了 IE 不允许我按 Enter 键提交表单的问题。我找到了部分解决方案(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>  

【问题讨论】:

    标签: jsf-2 primefaces


    【解决方案1】:
    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 中,以便它可以成为更新属性的目标。

    【讨论】:

      【解决方案2】:

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

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

      你想把它应用到 Professor 小部件变量

      【讨论】:

        猜你喜欢
        • 2019-11-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多