Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
FileDownloader on detach
There is a logic in my project: whenever I click button, it starts downloading file and closes window it is on. So the button is being detached from document also. At the same time component connector is removing iframe, being used as stream download link. So it dissapears faster then the download process begun if i'm downloading file from distant server.
@Override
public void setParent(ServerConnector parent) {
super.setParent(parent);
if (parent == null && iframe != null) {
//The place where iframe is being detached when the component is detached
iframe.removeFromParent();
}
}
Quick fix idea I can imagine is to leave the iframe where it is, and remove it whenever we click public void onClick(ClickEvent event) event.
I have this problem, FileDownloader make every time an iframe element on page when I click download, if I click download more time, every time the browser show download window more times...
I have hidden the download button: I use this code:
downloadButton.setVisible(true);
fd = new FileDownloader(res);
fd.extend(downloadButton);
Page.getCurrent().getJavaScript().execute("document.getElementById('DownloadButtonID').click();"
+ "document.getElementById('DownloadButtonID').style.display = 'none'");
fd = null;
to start the download after data export activated by another button.