我創建了一個簡單的primefaces 4.0表格,支持行編輯和列排序。我創建了兩個條目並將其降序排序。現在,當我使用行編輯器更改一行的值時,在保存行被其他行的數據覆蓋之後!當我重新加載表格時,一切都恢復正常。Primefaces:表格排序和行編輯不能一起工作
這是所有步驟:
- 與Spring ROO(有三串場只有一個實體)在pom.xml中創建一個簡單的項目
- 設置primefaces到4.0版本,並改變了源代碼到primefaces 4.0。
- 增加了對錶格的行編輯和列排序。
- 啓動服務器並輸入所有值爲「1」的第一個條目和所有值爲「2」的第二個條目。
- 對任何列進行降序排序(結果:「2」在最上面,「1」在最下面)
- 使用RowEditor編輯任何值並保存。
- 現在編輯行的值會被視圖中其他行的值覆蓋。
這是我的JSF代碼:
<p:dataTable editable="true" id="list" value="#{customerBean.allCustomers}" var="customer" rendered="#{customerBean.dataVisible}" resizableColumns="false" paginator="true" paginatorTemplate=" {CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,25,50" rows="10">
<p:ajax event="rowEdit" listener="#{customerBean.onRowEdit}" update=":growlForm:growl" />
<p:columns value="#{customerBean.columns}" var="column" columnIndexVar="colIndex"
sortBy="#{customer[column]}">
<f:facet name="header">
<h:outputText value="#{applicationBean.getColumnName(column)}" />
</f:facet>
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{customer[column]}" /></f:facet>
<f:facet name="input"><p:inputText id="#{customer[column]}Input" value="#{customer[column]}" style="width:96%"/></f:facet>
</p:cellEditor>
</p:columns>
<p:column style="width:6%">
<p:rowEditor />
</p:column>
而這個服務器代碼:
public void onRowEdit(RowEditEvent event) {
this.setCustomer((Customer) event.getObject());
this.persist();
}
它是袋鼠的一個bug,Primefaces的,JSF的或JQuery的的??? 任何提示或解決方法?行編輯後刷新表格最簡單的方法是什麼,而不會丟失當前的排序和分頁?
謝謝! 亞歷