2012-09-17 53 views
0

我有這樣的代碼:文本菜單操作後的數據表未更新

  <p:contextMenu for="customersTable"> 
      <p:menuitem value="Delete" update="customersTable" icon="ui-icon-close" actionListener="#{customerbean.onDeleteCustomer}"/> 
      </p:contextMenu> 


      <p:dataTable id="customersTable" var="customer" widgetVar="customerTable" value="#{customerbean.customerList}" paginator="true" rows="20" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="10,20,50,100" emptyMessage="#{text['table.customer.filter.notfound']}" filteredValue="#{customerbean.filteredCustomers}" editable="true" draggableColumns="true" rowKey="#{customer.id}" selection="#{customerbean.selectedCustomer}" selectionMode="single"> 

我的問題是,當我點擊的文本菜單的「刪除」,一切都在這個意義上做工精細的記錄/行正在通過bean方法調用從後端擦除,但是表未反映新數據的更新。

+0

您必須爲更新屬性的數據表提供完整的組件ID,例如update =「formid:datatableid」 – PermGenError

回答

1

您必須在更新時爲dataTable提供完整的組件ID。

<h:form id="frm"> 
    <p:contextMenu for="customersTable"> 
     <p:menuitem value="Delete" update="frm:customersTable" icon="ui-icon-close" actionListener="#{customerbean.onDeleteCustomer}"/> 
     </p:contextMenu> 
     <p:dataTable id="customersTable" var="customer" widgetVar="customerTable"   value="#{customerbean.customerList}" paginator="true" rows="20" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="10,20,50,100" emptyMessage="#{text['table.customer.filter.notfound']}" filteredValue="#{customerbean.filteredCustomers}" editable="true" draggableColumns="true" rowKey="#{customer.id}" selection="#{customerbean.selectedCustomer}" selectionMode="single"> 



</h:form> 
+0

我已將prependId設置爲false。當我輸入完整的ID時,我得到這個異常:javax.servlet.ServletException:找不到帶有標識符ba的組件 – javaMS

+0

你能否發佈異常請 – PermGenError

+0

我不能發佈全部,但它就像我在前一篇文章中寫的:SEVERE :錯誤呈現視圖[/viewCustomerList.xhtml] javax.faces.FacesException:無法找到標識爲「ba :customersTable」的引用自「j_idt34」的組件。 在org.primefaces.util.ComponentUtils.findClientIds(ComponentUtils.java 273) 在org.primefaces.util.AjaxRequestBuilder.addIds(AjaxRequestBuilder.jav :102) 在org.primefaces.util.AjaxRequestBuilder.update(AjaxRequestBuilder .jav :90) – javaMS

0

好吧,我發現了什麼問題 - 相當微不足道。我從數據庫中刪除它,但不是從Primefaces用於在屏幕上顯示它的集合中刪除它。它需要從兩者中刪除。

+0

但你爲什麼得到SEVERE:錯誤渲染視圖[/viewCustomerList.xhtml] javax.faces.FacesException:找不到具有標識符「ba:customersTable」引用自「j_idt34」的組件。在 ?? – PermGenError

+0

我只有在回答您的答案時纔會這樣做,即我必須預先填寫表格名稱。 – javaMS