ui-changes inside a FileDownloader are lost (sometimes)

I want to create a download-button, but it can happen, that the needed InputStream can not be created.
So i want to show the user, that the download could not be created.

Example code:

final VerticalLayout mainLayout = new VerticalLayout();
StreamResource streamResource = new StreamResource(() →
// Something went wrong. Thus we can not deliver an InputStream
mainLayout.addComponent(new Label("Problem at time: " + System.currentTimeMillis()));
return null;
}, “file.dat”);

Button downloadButton = new Button(“click to download”);
FileDownloader fileDownloader = new FileDownloader(streamResource);

[/code]If the button is clicked two requests are triggered, one for the gui (
) and one for the download (
Sometimes (not every time) the sequence of these requests is not correct. I suggest using Chrome to reproduce the problem.
The correct sequence is
first and
second, so that ui-changes are handled after the download was initiated.

If the sequence is wrong, i have no chance to inform the user (in my example add a new label to the UI) about the error, because the ui-changes are not communicated to the client.

The question is: Is there a possibility to trigger another request to refresh the UI?

I am using vaadin 7.7.9

A possible solution would maybe the
feature, but this is unfortunately no option for me.

Try to use Notification instead of adding a label.

I don’t think the framework gives any guarantees on the order, and it seems to me that the point at which the stream is generated is indeed often too late and not handled by the same request handle.

Why is push not an option for you? How about UI.setPollInterval(ms) (which you could activate in a click listener on the button if you don’t want to have it active all the time) if you can’t use push?

Thanks for your responses.
We decided to make a cache for the stream-creation. This cache is used from the FileDownloader and from a clickListener on the button. (We cached the stream-creation because it is maybe a heavy operation.) If the stream was created properly the download starts, if the creation of the InputStream failed we perform the UI-operation inside the clickListener.