Hi, I use rich:extendedDataTable with rich:datascroller to display children of a folder. When I add some new items in the folder, I want to display them in the table with the following function in my subclass of ExtendedDataModel:
public void displayNewObjects(Collection<ObjectBean> newObjects) { if (this.selection != null) { this.selection.clear(); } else { this.selection = new SimpleSelection(); } for (ObjectBean o : newObjects) { ObjectBeanRowAdapter newObjectItem = new ObjectBeanRowAdapter(o); this.dataItem = newObjectItem; this.cachedItems.add(0, newObjectItem); this.selection.addKey(newObjectItem); } }
If the table contained some rows before, it works fine by adding the new rows to the table for the new objects. But if the table was empty, "No Data" will still be there and the new rows are appended to it.
I am doing it in this way because I want the user to see the new items immediately. If I go back to the database after the creation, the new objects may not display in the table due to the pagination.
Any suggestion will be appreciated.
-ZJ
Hi, I have solved the problem by add the following code to the mathod displayNewObjects(Collection<ObjectBean> newObjects):
if (this.rowCount == 0) {
this.rowCount = this.cachedItems.size();
}
Cheers,
-ZJ