Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Table with LQC very slow for setCurrentPageFirstItemIndex
We are using Vaadin Table with lazy query container (LCQ) in many scenarios. Today we are facing one problem when using Table + LCQ + setCurrentPageFirstItemIndex. The scenario is that the table presents a huge number of items (~ 20.000) where in some situations the user wants to investigate so called hot spots. Hot spots are ranges of items which the user wants to analyse - the hot spots are known in advance and so we added two buttons labled "prev hot spot" "next hot spot".
One field of the DB table corresponse to the index which fits pretty well to LQC's item-id index (thus btw LQC uses its
NaturalNumberIdsList in order to speed up calls to getItemId etc).
When "next hot spot" is pressed we know the index and also the itemId and so we can easily select the item and call
setCurrentPageFirstItemIndex (or even setCurrentPageFirstItemId) so that the table is scrolled to the next hot spot.
The problem is that the larger the leap from the current position to the target position the longer it takes to update the table.
In my test scenario the browser XHR request is pending for more than 40 seconds in some cases.
I found that Vaadin Table iterates over all items which - in turn - causes LQC to load all item between the current item and the target item. The loop in question is inside com.vaadin.ui.Table#unregisterComponentsAndPropertiesInRows. Here Vaadin unregisters event listeners (we don't use)...
I saw that setCurrentPageFirstItemIndex(pos) simply delegates to setCurrentPageFirstItemIndex(pos, true) - where true indicates to reset the page buffer. setCurrentPageFirstItemIndex(int, boolean) however is package private so I can call it only using reflection - which I tried. In turns out that calling setCurrentPageFirstItemIndex(pos, false) solves the performance problems, but this is only a hack since I cannot call it directly.
We are using Vaadin 7.1.10 at the moment and might upgarde to a higher version in the next months. However we need a quicker solution because the application is already used in production.
Thanks in advance for any hints and suggestions on this.
I guess your best bet would be to subclass the Table and add implement setCurrentPageFirstItemIndex(pos, true) manually. It seems like this method doesn't use private stuff of the Table so this should be doable.
Ok, I will check this out - thanks for the hint.
BTW - are there any possible drawbacks when setting the current-page-first-item-index without resetting the page buffer?