With PrimeFaces 6.1, When I implement a LazyDataModel on a Datatable with virtualScroll, the fisrt page row is duplicate.
See this exemple with bean Item, LazyDataModel implementation and BrowserItems view :
Code: Select all
public class Item {
private Integer itemIndex;
private String itemValue;
public Item(Integer itemIndex, String itemValue) {
this.itemIndex = itemIndex;
this.itemValue = itemValue;
}
public Integer getItemIndex() {
return itemIndex;
}
public void setItemIndex(Integer itemIndex) {
this.itemIndex = itemIndex;
}
public String getItemValue() {
return itemValue;
}
public void setItemValue(String itemValue) {
this.itemValue = itemValue;
}
}
Code: Select all
public class LazyItemDataModel extends LazyDataModel<Item> {
private List<Item> itemList;
private List<Item> itemLazyList;
public LazyItemDataModel() {
this.itemList = new ArrayList<Item>();
for (Integer i=0; i<=450; i++) {
this.itemList.add(new Item(i, "ITEM - "+ i));
}
}
@Override
public Item getRowData(String rowKey) {
return this.itemList.get(Integer.parseInt(rowKey));
}
@Override
public Object getRowKey(Item item) {
return item.getItemIndex();
}
@Override
public List<Item> load(int first, int pageSize, List<SortMeta> multiSortMeta, Map<String, Object> filters) {
this.itemLazyList = this.itemList.subList(first, first+pageSize);
this.setRowCount(this.itemList.size());
return this.itemLazyList;
}
public List<Item> getItemLazyList() {
return itemLazyList;
}
public void setItemLazyList(List<Item> itemLazyList) {
this.itemLazyList = itemLazyList;
}
}
Code: Select all
@ManagedBean
@ViewScoped
public class BrowserItem implements Serializable {
private LazyDataModel<Item> listLazyDataModel;
public BrowserItem() {
}
@PostConstruct
public void init() {
listLazyDataModel = new LazyItemDataModel();
}
public LazyDataModel<Item> getListLazyDataModel() {
return listLazyDataModel;
}
public void setListLazyDataModel(LazyDataModel<Item> listLazyDataModel) {
this.listLazyDataModel = listLazyDataModel;
}
}
Code: Select all
<h:form id="browseItem" prependId="false" >
<p:dataTable id="result" widgetVar="result"
var="item" value="#{browserItem.listLazyDataModel}"
rowKey="#{item.itemIndex}"
scrollable="true" scrollHeight="500" scrollWidth="100%" reflow="true"
sortMode="multiple" virtualScroll="true" scrollRows="50" lazy="true" liveScroll="true"
>
<p:column sortBy="#{item.itemValue}" filterBy="#{item.itemIndex}" priority="2">
<h:outputText value="#{item.itemIndex}"/>
</p:column>
<p:column sortBy="#{item.itemValue}" filterBy="#{item.itemIndex}" priority="2">
<h:outputText value="#{item.itemValue}"/>
</p:column>
</p:dataTable>
</h:form>
After the first refresh, every thing look like ok (unless blanck page when each refresh)
Is it an issue OR is it a wrong property use for this type of Lazy Datatbel Scrolling?
Thanks a lot for your help.