Label: update value from another thread

Is it possible to update Label value from another thread?
For example this code runs well:

String res = executeFunction();

but this code fails to update Label:

new Thread()
	public void run()
			String res = executeFunction();

I want to do the following: user presses button, some function is running in another thread what makes possible the user to make some actions while function is running. After function ends, label shows the appropriate message.

Can’t say directly what’s wrong with your code, but what you want is possible. The Book gives a complete example in the section on

I put the example also
, so you can see how it works. You can see the (most recent) source code there as well.

There is no need to call requestRepaint() as it is called automatically when the value of the component changes.

The problem you struck into is probably what Marko hinted of - server changes can not be pushed to the client. All changes you do outside the main thread, kicked in action by the user, will not be reflected to the end user until that user (or the users browser) sends a request to the server. When this client request is activated, however, all the changed data in the components will be swooped along in that roundtrip automatically.

As Marko already showed, you can use ProgressIndicator to poll the server every once in a while. Your label changes will tag along with the polling roundtrips. There is a little more lightweight component called the Refresher that does the same thing, but it isn’t part of the core Vaadin framework. Search the forum for it. Pure push functionality is on the drawing board.

2 Marko - thanks for your example
2 Jens Jansson thanks for reply. Adding ProgressIndicator helps to update changes.
One more question

What do you mean by drawing board?

I mean that the Vaadin development team is looking into bulding push functionality into Vaadin, so that we don’t need to poll the server all the time. We’ll get it at some point in the future, if they decide to implement it.