I would like to write a application that runs a thread to periodically update a Label on the client browser with some map (lat,lon) coordinate info.
I am new to Vaadin, but I understand that HTTP lacks server-side push capability. I’ve seen some forum posts that suggest using ProgressIndicator to pull client updates from the server.
Is it possible to initiate polling requests to the server directly from a client’s widget? or is the ProgressIndicator hack the only way?
You’re correct in that there isn’t any support for HTTP push in Vaadin and we usually use the ProgressIndicator to accomplish periodical updates of the client (UI).
The way the ProgressIndicator works is that it periodically asks the server for updates to itself - e.g. it requests the “fill amount” of a progress bar (or whatever shape it might be). The reason this works for refreshing the entire UI is that as a side effect of the ProgressIndicator requesting the changes to itself, the server sends
all pending changes . This means that if one component requests an update, all pending updates to all visible components are sent from the server.
You could also check out the “Refresher” component by Henrik. It’s quite a bit easier to use, as it doesn’t require explicit hiding in CSS. And the “Refresher” is also a good example of how to initiate polling requests from any widget. There’s a thread about the “Refresher”
here .
To add to Jonatans reply: If you write your own widget, you can trivially request a server poll at any time by simply updating any variable and doing client.sendPendingVariableChanges().
Here is a simple example .