当ajax禁用页面中的组件验证失败时,Primefaces会停止选项卡导航

时间:2015-03-26 05:55:39

标签: jsf jsf-2 primefaces

如果在页面的第二个标签页中单击按钮时组件验证失败,如何停止页面导航到第一个标签页。

我还需要使用primefaces验证和ajax禁用功能。

我在选项卡中有一个按钮,用于下载文件,因此在此按钮上禁用了ajax功能。当我手动输入无效日期并直接单击下载按钮时,验证失败,并在页面的第一个选项卡上显示错误消息。

我的主页包含标签:

  <?xml version="1.0" encoding="ISO-8859-1" ?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:p="http://primefaces.org/ui" template="/menu.xhtml"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:pe="http://primefaces.org/ui/extensions">
<ui:define name="body">

  <p:tabView dynamic="true" cache="false" id="tabView" widgetVar="cmtmtTabs" binding="#{tabsController.tabView}">  
   <p:ajax event="tabChange" listener="#{tabsController.onTabChange}"/>

    <p:tab id="insuranceTab" title="Insurance" >  

        <ui:include src="insurance.xhtml" />

    </p:tab>

    <p:tab id="transferReportTab" title="Transfer Report" >  

        <ui:include src="transferReport.xhtml" />

    </p:tab>

   </p:tabView>

</ui:define>

带有按钮的我的XHTML页面:

<?xml version="1.0" encoding="ISO-8859-1" ?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions" 

    <div class="container">
        <div class="main-context" id="scrollArea">
            <h:body class="bgcolor">

            <p:ajaxStatus onstart="statusDialog.show();"
                    onsuccess="statusDialog.hide();" />
                <p:accordionPanel id="searchCriteriaAcrdPnl" width="100%" styleClass="panelNormal">
                    <p:tab id="loanSelectionFieldsTab" title="Loan Selection Fields">
                        <h:form id="criteriaForm">
                        <p:messages id="errorMessages"></p:messages>
                            <p:panelGrid  id="searchCriteriaPnlGrd" styleClass="noborder" style="width:100%">
                                <p:row>
                                    <p:column styleClass="talign-top">
                                        <p:panelGrid id="dateFilterPnlGrd" styleClass="noborder">
                                            <p:row>
                                                <p:column styleClass="ralign">
                                                    <h:outputText id="lblClosingDtFrom"
                                                        value="Closing Date From:" />
                                                </p:column>
                                                <p:column styleClass="fixedSelect">
                                                    <p:calendar id="closingdtFrmCal"
                                                        value="#{myController.closingDateFrom}"
                                                        showOn="button" pattern="MM/dd/yyyy" converterMessage="Please Enter a Valid Closing From Date" validatorMessage="Please Enter a Valid Closing From Date"
                                                        maxdate="#{myController.closingDateTo}"  
                                                        onkeypress="if (event.keyCode == 13){return false;}else{return true;}">
                                                        <f:convertDateTime pattern="MM/dd/yyyy" />
                                                        <p:ajax event="dateSelect"   update="closingdtToCal,errorMessages  " global="false"></p:ajax>
                                                    </p:calendar>
                                                </p:column>
                                                <p:column styleClass="ralign">
                                                    <h:outputText id="lblClosingdtTo" value="To:" />
                                                </p:column>
                                                <p:column styleClass="fixedSelect">
                                                    <p:calendar id="closingdtToCal"
                                                        mindate="#{myController.closingDateFrom}"
                                                        value="#{myController.closingDateTo}"
                                                        showOn="button" pattern="MM/dd/yyyy" converterMessage="Please Enter a Valid Closing To Date" validatorMessage="Please Enter a Valid Closing To Date"
                                                        onkeypress="if (event.keyCode == 13){ return false;}else{return true;}">
                                                        <f:convertDateTime pattern="MM/dd/yyyy" />
                                                        <p:ajax event="dateSelect"   update="closingdtFrmCal,errorMessages" global="false"></p:ajax>
                                                    </p:calendar>
                                                </p:column>
                                            </p:row>
                                        </p:panelGrid>
                                    </p:column>
                                    <p:column>
                                            <p:row>
                                                <p:column colspan="2" styleClass="ralign">
                                                    <p:commandButton id="transferListCmdBtn" value="Transfer List" ajax="false" action="#{myController.exportToList()}" upadte="errorMessages" />
                                                </p:column>
                                            </p:row>
                                        </p:panelGrid>
                                    </p:column>
                                </p:row>
                            </p:panelGrid>
                        </h:form>
                    </p:tab>
                </p:accordionPanel>
            </h:body>
        </div>
    </div>

0 个答案:

没有答案