Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Page Load event in vaadin

Tags:

vaadin

I have page with table that populates data based on complex query(takes lot of time even though I use pagination). I use BeanItemcontainer to load data in to the table. Now coming to the problem, I wish to load the data in to the table in a async way(after the complete page gets loaded on the user screen. I wan to populate the data). Is there some thing like onPageLoad event or onPageRenderEvent or equivalent that I can use to achieve this?

Details -

Version - Vaadin -7.0
Component - Table
Data Container - BeanItemContainer.

like image 923
Patton Avatar asked Oct 04 '22 17:10

Patton


1 Answers

There's a number of ways to solve this, but you have to decide how you want to approach the problem. Here's two that I know of:

1) Request from the client.
2) Push from the server. (technically still a request from the client)

1 -- A) Request from a Javascript function programmed on the client-side. Attach the component to a layout by using a Javascript Extension or a Javascript component and make requests by calling a server-side API function. You can then update the table within that request and not worry about syncing issues.

1 -- B) Make your own GWT / Vaadin widget (same thing, basically) to do 1A.

2 -- A) Request from a Vaadin component programmed on the "server-side." Make a visible (or invisible) progress indicator that polls the server. Populate the table in a background thread and Vaadin will send the data you've currently gathered. The progress indicator can do this many times and the table will only send the difference to the client-side code (called the delta). Be careful updating client-facing components from background threads; you need to sync on changes to the component to avoid concurrent modification errors.

2 -- B) Add a refresher to the application and follow 2A above without needing a progress indicator.

Either solution involves you explicitly updating the table, either in a background thread (2A,B) or in the server method called from the client (1A,B). And both are technically client-request based. The Vaadin team are working on adding true 'push.'

like image 93
Christopher Poile Avatar answered Oct 13 '22 12:10

Christopher Poile