Value of label do not changes when calling heavy-load-method

First, i want to thank you all for making this project possible. Designing Web-Applications makes so much fun with vaadin :slight_smile:

I’ve created an application, which is used for uploading Logfiles to analyse them and filter the results into Error/Warning and unhandled Exceptions. After i had implemented all functionality, i realized that when, e.g., a heavy-load method is called immediately after the value of a label has changed, the ui freezes and changes the value not until the heavy-load method has finished.

What do i have to do to get that value changed immediately in the ui?

	// changes value for visualyzing working state
	label.setValue("analyzing Logfile...");
	// start processing which creates heavy load
	startExceptionFilter();

I’m still new in developing Web-Applications or even Java so i don’t think that this is a bug of vaadin framework :wink:

A little bit on how HTTP-requests and thus ajax and Vaadin works: When you make an HTTP-request, the server receives your request, processes it and once the process is done, it returns some value. In traditional web pages, this return value is in HTML format, with Vaadin it is JSON. After the result has been returned, the browser then renders the result to the screen. What now happens in your application is that you set the new value to the label, the change is registered in Vaadin, but the JSON isn’t sent to the browser until the end of the HTTP-request - and the HTTP request doesn’t end until everything is processed, including your heavy loading process - in other words, the browser doesn’t get the order to change the label’s value until the process is completed. What you need to do is to run the heavy process in another thread, thus allowing the HTTP-request to reach an end and not depend on the heavy process.

If required, you can use the
ProgressIndicator
to visualize the process of your heavy operation in your user interface - or - if you do not need to visualize it, then you could, for example, use the
Refresher add-on
to poll the server to see when the process is done.

Thanks for the basics and good overview.

So i have to use implements Runnable and call the heavy load method with thread.start()? I read about threads but never used it before.

I was successfull in using threads. Calling heavy load method:


class UserInterface:
--------------------------------

    public void startExceptionFilter() {
		
    	ExceptionFilterBD filter = new ExceptionFilterBD(fileSystem.getUploadPath(), fileSystem.getDownloadPath(), fileSystem.getFilename());
    	Thread t = new Thread(filter);
    	t.start();
	}

	public static void syncronize(String status, float value) {
		synchronized (uploadAndSelectionVt2.getApplication()) {
			progressBar.setCaption(status);
			progressBar.setValue(value);
		}
	}

Refreshing UI with syncronize:


class ExceptionFilterBD:
--------------------------------

...
UserInterface.syncronize("still processing...", 0.25F);
...