Reputation: 37633
I have a GWT page with a listing (from the datastore) on it. I understand how I can get this listing after the page is loaded, with an async call, but I want to make sure that when the page is loaded initially, it has valid data in it. Otherwise, the page loads most of the way, and then the listing is filled in, which leads to a choppy load, and a longer time the user needs to wait before the page loads.
So, how can I get data from the server into the page when it loads? Is there a way to call the server-side service from the constructor of my UIBinder class? I can't call the actual service implementation, since the client-side code can't reference the server-side code, right?
Surely this can't be a unique need, but I can't seem to find any tips on Google (though I might not be searching the right terms).
Upvotes: 1
Views: 1025
Reputation: 1835
What I've done in my own project to solve the same problem is to use JSP to embed the data that I need into the page source as javascript objects. That way the data is already there by the time onModuleLoad() is called. Google have a bit of documentation on how to read javascript objects into your java code.
Obviously you'll need to know a little bit about jsp as well.
Upvotes: 1
Reputation: 11374
You could hide your whole page content until the data is loaded to avoid the choppy effect.
But the most user friendly way would be to display a loading message on your page load. Then in the success and failed events of your async call, after the data is bind, hide the loading message.
Upvotes: 0