2015-02-06 75 views
-1

我正在使用Primefaces。我有一個dataTable裏面的對話框,當我嘗試排序/過濾它,對話框關閉。我假設每當一個Ajax調用被關閉對話框。我也嘗試做一個「測試」示例按鈕,它也關閉對話框。 有沒有辦法防止這種情況發生?Dialog在ajax調用上關閉

<p:outputPanel autoUpdate="true" deferredMode="true" deferred="visible"> 
    <p:dialog height="700px" width="100%" closable="true" closeOnEscape="true" header="Sample table" widgetVar="sampleDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false"> 
     <h:form> 
      <p:dataTable id="fooTableCurrent" 
          var="business" 
          value="#{mainViewController.lazyModel}" 
          paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}" 
          paginator="true" rows="20" style="width: 100%; text-align: center;" 
          rowsPerPageTemplate="10,20,50,100,200" 
          emptyMessage="No records found with given criteria" 
          editable="true" 
          lazy="true" 
          scrollable="true" 
          scrollHeight="100px"> 


       <p:ajax event="rowEdit" listener="#{mainViewController.onBusinessRowEdit}" /> 
       <p:ajax event="rowEditCancel" listener="#{mainViewController.onBusinessRowCancel}" /> 

       <p:column headerText="Employee reg. #"> 
        <h:outputText value="#{business.employee.employee_ID}" /> 
       </p:column> 

       <p:column headerText="Employee"> 
        <h:outputText value="#{business.employee.name}" /> 
       </p:column> 

       <p:column headerText="Bank"> 
        <h:outputText value="#{business.bank.name}" /> 
       </p:column> 

       <p:column headerText="Office" filterStyle="width:60px;" filterBy="#{business.office.office_ID}" filterMatchMode="contains"> 
        <h:outputText value="#{business.office.name}" /> 
       </p:column> 

       <p:column headerText="Product group" style="width: 100px;"> 
        <h:outputText value="#{business.product.product_group.name}" /> 
       </p:column> 

       <p:column headerText="Product" filterStyle="width:60px;" filterBy="#{business.product.product_ID}"> 
        <h:outputText value="#{business.product.name}" /> 
       </p:column> 

       <p:column headerText="Contract" filterStyle="width:60px;" filterBy="#{business.contract}"> 
        <h:outputText value="#{business.contract}" /> 
       </p:column> 

       <p:column headerText="Value" sortBy="#{business.value}"> 
        <p:cellEditor> 
         <f:facet name="output"><h:outputText value="#{business.value}" /></f:facet> 
         <f:facet name="input"><h:inputText value="#{business.value}" /></f:facet> 
        </p:cellEditor> 
       </p:column> 

       <p:column headerText="Date" sortBy="#{business.insert_date}"> 
        <h:outputText value="#{business.insert_date}" /> 
       </p:column> 

       <p:column headerText="Approved" width="55" style="text-align: center;"> 
        <p:selectBooleanCheckbox disabled="true" value="#{true}" /> 
       </p:column> 

       <p:column style="width:32px" headerText="Edit"> 
        <p:rowEditor /> 
       </p:column> 

       <p:column headerText="Delete" width="30"> 
        <p:commandButton icon="ui-icon-close" actionListener="#{mainViewController.deleteBusiness(business)}" update="@form"> 
         <p:confirm header="Confirmation" message="Are you sure?" icon="ui-icon-alert" /> 
        </p:commandButton> 

        <p:confirmDialog global="true" showEffect="fade" hideEffect="fade"> 
         <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" /> 
         <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" /> 
        </p:confirmDialog> 

       </p:column> 
      </p:dataTable> 
     </h:form> 
    </p:dialog> 
</p:outputPanel> 
+0

此代碼非常嘈雜。當您刪除「員工」列時問題是否消失?沒有?請從您的代碼片段中省略它。當您刪除'paginatorTemplate'時問題是否消失?沒有?請從您的代碼片段中省略它。當您刪除'scrollable =「true」'時,問題是否消失?沒有?請從您的代碼片段中省略它。仔細閱讀http://stackoverflow.com/help/mcve並相應地修復您的問題。順便說一句,我最好的猜測是嵌套的形式。 – BalusC 2015-02-06 10:12:08

回答

1

問題出在outputPanel標籤。除去autoUpdate="true"之後,所有事情都充當魅力。

+0

感謝您的回答。我看到你現在增加了這個問題,下次請從一開始創建[mcve](http://stackoverflow.com/help/mcve)。 – Kukeltje 2015-02-06 17:35:05

0

您可以使用屬性oncomplete = 'PF.show('WIDGET_VAR_NAME)'強制再次顯示對話框。

+0

這是一種解決方法(補償),而另一個答案修復(刪除)原因。 – Kukeltje 2017-04-10 16:12:16

+0

在我的情況下,我找回了沒有任何'autoUpdate =「true」'的問題。我發佈了我的解決方案,因爲它適用於我。 – 2017-04-11 15:29:22

+0

好的,謝謝你的澄清,但是如果你有沒有'autoUpdate =「true」的問題(並且明確地更新了對話外的東西),那麼你實際上有一個不同的'問題' – Kukeltje 2017-04-11 15:35:19