I use streamResource to dynamically create files (after user click on the link) and then allow user to download the file. Sometimes it takes more than 10 seconds to create the file so I want to provide a waiting image or a related message and make inactive the link.
However, all the changes and the new window I provide are executed only when the file is ready for the download and not earlier.
Is there any way to provide a message at the beginning of the process to the user?
I am using Vaadin v8.
private StreamResource createResource(ExportItem exportItem, String exportType) {
return new StreamResource(new StreamResource.StreamSource() {
@Override
public InputStream getStream()
{
//Provide a new wait Popup window to let the user know about the delay
getView().showWaitPopup(true, "Your file is being generated!Please be patient.");
//the following getFile() method needs about 10-20 seconds to generate the file.
File file = getFile(exportItem, exportType);
try {
return new FileInputStream(file);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}, exportItem.getFilename());
}