Implemented the three methods and set the provider to Tree.
The problem is that the methods ‘getChildCount’ and ‘fetchChildrenFromBackEnd’ are gettinng called 4 times!
This causes major issues when using heavy queries.
The weird thing is that these methods get called 4 times even with zero child nodes.
example
public int getChildCount(HierarchicalQuery<ItemBean, Void> query) {
return 0;
}
protected Stream fetchChildrenFromBackEnd(HierarchicalQuery<ItemBean, Void> query) {
return new LinkedList().stream();
}
public boolean hasChildren(ItemBean item) {
return false;
}
Is this a known issue or expected behavior? What can I do to ensure the calls are made just once.
This is because internal logic of DataProvider is abstracted away from TreeGrid.
What can I do to ensure the calls are made just once.
The most straightforward way to help the situation is to use some mechanism of caching. Easiest approach is perhaps to use cache with your backend, like ehcache.
So, if there are 1000 nodes then there will be 8000 database calls made! Not to mention the poor user interface experience that will result from constant rendering of the tree structure.
I can try caching but am afraid it could grow tremendously as number of sessions grow and does not appear to be a solid solution.
Isn’t this a bug or some tree implementation issue? Why would these methods be called 4 times each? Does not make sense. I will open an issue in the link you provided so that the Vaadin team is aware of it.