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) {

FileResource fileResource = new FileResource(tmpFileErzeuger.addToZipFile());
FileDownloader fileDownloader = new FileDownloader(fileResource);

if (fileDownloader != null)

Keep a reference of fileDownloader and if it is not null remove it from downloadButton in buttonClick handler.

that gives me a exception.I can’t remove extentions in clickListener. I found that topic in 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() {
         return new FileResource(tmpFileErzeuger.addToZipFile());        

It is a good solution. Thanks!