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:
[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);
fileDownloader.extend(downloadButton);
mainLayout.addComponent(downloadButton);
[/code]If the button is clicked two requests are triggered, one for the gui (
uidl
) and one for the download (
dl
).
Sometimes (not every time) the sequence of these requests is not correct. I suggest using Chrome to reproduce the problem.
The correct sequence is
dl
first and
uidl
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?