Updating UI component after buttonClick not working as expected


I have a problem with a Button Clicklistener that is driving me crazy and I can’t figure out how to do it right.
I hope you folks can help me out. We are using Vaadin 6.7.3.

Our application uses the BorderLayout add on and after click on a button a long running computation is done. To keep the user informed about what is going on a text in a status bar which is placed at the bottom of the window (BorderLayout.SOUTH) should be displayed
the long running task begins and the standard Vaadin loading indicator is shown.

The code for the onClick listener is pretty straight forward and looks like this:

final Button updateDataButton = new Button("Update Data");

    updateDataButton.addListener(new Button.ClickListener() {
      public void buttonClick(ClickEvent event) {
        updateStatusBar("Updating data ...");
    addComponent(updateDataButton, 2, 15, 3, 15);

The method
changes the text of the label with the status information in the status bar. A call to
starts the long running task. The problem is, that the long running task starts and the Vaadin loading indicator is shown and
the task has finished, the statusbar text is changed. The
method doesn’t start any threads or parallel tasks. We don’t use a progress indicator and we don’t want to use is. Please don’t ask why :slight_smile: What am I doing wrong?
According to the code above the label in the status bar should be updated
the task and the loading indicator is shown?

I tried a few simple variations to see if it is general problem. For example, I changed the caption of the Button

a call to
and the caption also changed
the long running task finished.

The long running task runs approx. 30 seconds. But the problem is independent of the time. Even if the task runs for 1 seconds the problem is still there.

So I am pretty sure I am doing something wrong but I can’t figure out what. I greatly appreciate any help on this.

Thanks in advance.


So you are not using threads, but instead operating a long running task that effectively blocks the UI thread?

When you call a method that sets a value of a Label or does anything, which needs a repaint (sending changes to browser), it doesn’t mean that the change is immediately sent to browser and your code continues executing after the method call. Instead Vaadin engine collects all the changes and then sends the changes in an http response. Now when your long running task is blocking the UI thread in the event listener, the response containing the changes is also waiting for the task to complete.

If you really want to use synchronous call and don’t want to use ProgressIndicator, you somehow need the client side to generate an event after you’ve updated the status bar and in that event listener you start the long running operation.