我構建了一個相對簡單的數據表,並嘗試使用過濾器功能並使用分頁功能。Primefaces 4.0 - 分頁數據表過濾問題
參照primefaces showcase我爲我的Customer
類中的每個字段創建了一列。
這是我的「控制器」豆:
@SessionScoped
@Named
public class CustomerListController implements Serializable{
public static final long serialVersionUID = //UID;
private List<Customer> filteredCustomers;
private List<Customer> allCustomers;
public CustomerListController(){
//some Class that generates a list of sufficiently many
//dummy customers on instantiation
this.allCustomers = new CustomerListProducer().getCustomers();
}
public List<Customer> getFilteredCustomers{
return this.filteredCustomers;
}
public void setFilteredCustomers(List<Customers> list){
this.filteredCustomers = list;
}
public List<Customer> getAllCustomers(){
return this.allCustomers;
}
}
我用下面的dataTable呈現此:
<p:dataTable paginator="true" rows="18" scrollRows="15" scrollable="true"
scrollHeight="500" var="customer" value="#{customerListController.allCustomers}"
scrollable="true" id="customerTable"
filteredValue="#{customerListController.filteredCustomers}" widgetVar="table">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Search all fields:" />
<h:inputText id="globalFilter" onkeyup="table.filter()" />
</p:outputPanel>
</f:facet>
<p:Column id="nameColumn" filterBy="name" sortBy="name"
headerText="Customer" filterMatchMode="contains">
<h:outputText value="#{customer.name}" />
</p:Column>
<!-- Some more columns in the exactly same
manner as this changes only in Customer attribute-->
</p:dataTable>
當我按在任何給定的過濾器領域中的任何鍵的表失去所有行即使在清除字段時也不會顯示任何字段。
刷新頁面時,我得到預期的行數&頁面。
我會盡量按要求提供修改。
編輯:
我使用的是安裝了Maven的Primefaces版本4.0.0。
我一直在FF下挖掘控制檯,發現以下內容:
響應XML爲空,保存已更新表的節點條目。沒有引發JavaScript錯誤,隨着「表格數據」發送的視圖狀態ID隨每次擊鍵都發生變化。
我不明白它是如何顯示過濾的數據,即使刷新頁面後。 'filterBy'屬性必須接收客戶的字段'name'。請參閱primefaces用戶指南的第135頁。希望它有幫助^^ – Cold
是的我的朋友@ Vogel612。 – Cold
什麼是你的primefaces版本? – Cold