【问题标题】:How to not have a pop up if validation has failed如果验证失败,如何不弹出
【发布时间】:2014-03-21 22:30:31
【问题描述】:

只是一个简单的问题,但让我很恼火

基本上我有一些验证,用户必须在继续之前选择一个单选按钮,当我按下提交按钮时,我收到 ajax 消息告诉我需要选择一个单选按钮,但我也从通知用户标记的命令按钮,除非验证成功,否则无论如何都禁用弹出窗口

这是单选按钮的代码

<p:column>  
                        <br></br>
                        <p:selectOneRadio id="radioButtons" value="#{formBean.number}" layout="grid" columns="1"   required = "True"
                                          requiredMessage="#{bundle.messageSelectMarkRange}" > 
                            <f:selectItem itemLabel="0 - 19" itemValue="1" /> 
                            <f:selectItem itemLabel="20 - 39" itemValue="2" />  
                            <f:selectItem itemLabel="40 - 49 " itemValue="4" />
                            <f:selectItem itemLabel="50 - 59" itemValue="5" />
                            <f:selectItem itemLabel="60 - 69" itemValue="6" />  
                            <f:selectItem itemLabel="70 - 79" itemValue="7" />  
                            <f:selectItem itemLabel="80 - 100" itemValue="8" />  
                            <p:ajax process="@this" update="mySpinnerPanel comments" />
                        </p:selectOneRadio>  
                    </p:column>

这是命令按钮

        <p>
            <p:commandButton value="#{bundle.buttonNextSection}"  icon ="ui-icon-disk" update="displayMark :growl" oncomplete="PF('dlg').show()" /> 
        </p>
        <p:dialog header="Confirm Mark" widgetVar="dlg" showEffect="fold" hideEffect="fold">  
            <h:panelGrid id="displayMark" columns="2" cellpadding="5">  
                <h:outputText value="Mark to be submitted: " />  
                <h:outputText value="#{markingBean.markSectionOne.markSectionOne}" />  
                <h:outputText value="For student number : " />
                <h:outputText  value="#{markingBean.studentNumber}" />
                <p:commandButton action="#{markingBean.markSectionOne}" value="#{bundle.buttonSave}" update=":growl" icon="ui-icon-disk"/>
              <!--  <p:button outcome="/lecturer/marking/marking-section-two" value="#{bundle.buttonNextSection}"  icon ="ui-icon-arrowthick-1-e" />
                -->
            </h:panelGrid>  
        </p:dialog>  

如果验证不成功,我只想停止弹出对话框

谢谢

【问题讨论】:

    标签: jquery validation jsf jsf-2 primefaces


    【解决方案1】:
    <p>
        <p:commandButton value="#{bundle.buttonNextSection}" icon="ui-icon-disk"
            update="displayMark :growl checkValidation" />
    </p>
    
    <p:panelGroup id="checkValidation">
        <h:outputScript rendered="#{facesContext.validationFailed}">
            PF('dlg').show();
        </h:outputScript>
    </p:panelGroup>
    
    <p:dialog header="Confirm Mark" widgetVar="dlg" showEffect="fold" hideEffect="fold">
        <h:panelGrid id="displayMark" columns="2" cellpadding="5">
            <h:outputText value="Mark to be submitted: " />
            <h:outputText value="#{markingBean.markSectionOne.markSectionOne}" />
            <h:outputText value="For student number : " />
            <h:outputText value="#{markingBean.studentNumber}" />
            <p:commandButton action="#{markingBean.markSectionOne}"
                value="#{bundle.buttonSave}" update=":growl" icon="ui-icon-disk" />
            <!-- <p:button outcome="/lecturer/marking/marking-section-two" value="#{bundle.buttonNextSection}" 
                icon ="ui-icon-arrowthick-1-e" /> -->
        </h:panelGrid>
    </p:dialog>
    

    参考:https://stackoverflow.com/a/15384529/1602621

    【讨论】:

      猜你喜欢
      • 2023-03-22
      • 2017-03-13
      • 1970-01-01
      • 2013-09-07
      • 1970-01-01
      • 2015-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多