Table/TreeTable/Grid LazyLoading

Hi,

I’ve understood from previous posts that the OOTB lazy loading of Vaadin is automagically handled to that the client only fetches the needed rows from the server. Is there any way on the server side to know which rows are being fetched to the client?

I have a case where the customer can search for products but some additional information is fetched from a web service (current stock etc) and I don’t want to perform background searches for thousands of rows that are never going to be needed. If I would know that e.g. rows 100-130 were just fetched to the client, I could start a background thread for those and push the results to the UI as the calls return from the service…

Thanks in advance,
Nik

Hi Nicklas,

sure. Your displaying component (e.g. Table) is fetching only those rows it needs to display, from
a Vaadin Container. Collecting Items in Containers | Vaadin Data Model | Framework | Vaadin 7 Docs
https://vaadin.com/api/framework/com/vaadin/data/Container.html

You might want to have a look at this add-on:

Now, to answer your question, you can of course use a Container implementation that records
which Items are being fetched and when.

Either do do a white-box “extends” derivation and override methods needed, delegating to the
super class using ‘super’ calls when finished with recording.

Or use the Delegation pattern Delegation pattern - Wikipedia to create a
Container interface implementation that records the access then delegates to the real Container.
Standard OO stuff I think.

HTH,
–Enver

Thanks for the reply.

Yep, looks like it should be possible to attach a thread in getItem(Object) that would fetch the information in the background and push it to the property (and the UI with a push) when it’s done…