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.
How to remove button extensions in vaadin?
Following code creats an XML file, compress (zip) (each zip file has a new file name) and finally downloads it to the computer. But each time I change someting and press the button to make the program do all these steps in order to create a new zip file, I get the old file and the new created zip file together. I actually dont want to keep the old one, only the newly created file. Has anybody an idea what should be changed?
downloadButton.addClickListener(new Button.ClickListener() {
public void buttonClick(Button.ClickEvent event) {
tmpFileErzeuger.erzeugeXMLDatei(selectedItems);
FileResource fileResource = new FileResource(tmpFileErzeuger.addToZipFile());
FileDownloader fileDownloader = new FileDownloader(fileResource);
fileDownloader.extend(downloadButton);
}
});
if (fileDownloader != null)
{
downloadButton.removeExtension(fileDownloader);
}
Keep a reference of fileDownloader and if it is not null remove it from downloadButton in buttonClick handler.
Hi,
that gives me a exception.I can't remove extentions in clickListener. I found that topic in forum vaadin.com/forum/#!/thread/2581494/2581493. But I can't use these methods . I want to download the selected row from a table. Do you know any alternative to FileDownloader. At the beginning I have no resource. FileDownloader wants a resource in constructor.
I don't know if it could be a good solution, but what about moving resource creation logic from click listener to FileDownloader.getFileDownloadResource?
FileDownloader f = new FileDownloader(new StreamResource(null, null)) {
@Override public Resource getFileDownloadResource() {
tmpFileErzeuger.erzeugeXMLDatei(selectedItems);
return new FileResource(tmpFileErzeuger.addToZipFile());
}
};
f.extend(downloadButton);