File Chooser for downloading multiple files


Is there any component in Vaadin 7 using which we can display file chooser to download selected multiple files?

You might have a look at the MultiFileUpload add-on

Thanks Koenraad for your reply. But that add-on in not applicable for me as it is used for uploading files. I want the functionality for downloading multiple files.

Hi Rasika,
Indeed, I got it wrong.

For multiple file download, I don’t know whether a filechooser solution is available. I have tried using the standard FileDownloader in combination with Grid. In fact, I am extending several FileDownloaders to one button.
After selecting files and clicking on the multidownload button, all are downloaded simultaneously in the default download folder.

It’s not working perfect yet…

//... define layout with components

multiDownload = new Button("Multiple Download");
multiDownload.addClickListener(new ClickListener() {
    public void buttonClick(ClickEvent event) {
        //after clicking and downloading, remove the FileDownloaders linked to the button
        //todo : wait for end of download before removing extensions
        Iterator<Extension> extensionIterator = multiDownload.getExtensions().iterator();
        while (extensionIterator.hasNext()) {

//... define Grid and add a column containing a button to select the files to be downloaded
grid.addColumn("FileName", String.class);
grid.addColumn("Button", String.class);
     new ButtonRenderer(e -> selectPressed(grid.getContainerDataSource().getItem(e.getItemId()))));

... fill the Grid with files
grid.addRow(fileName,.... , "select");

.. the rest of your UI

private void selectPressed(Item selectedItem) {
    String fileName = (String) selectedItem.getItemProperty("FileName").getValue();
    //my files are located in the temp folder
    FileResource fileResource = new FileResource(new File(System.getProperty("")
         + "demo//" + fileName));
    FileDownloader fileDownloader = new FileDownloader(fileResource);

Hi Koenraad,

Its working!! Thanks a lot!! :slight_smile:

Hi Koenraad,

I am facing issues while running it in internet explorer. The IE version I am using is 9.

Also, I am not able to extend the same component once I have removed it.

Hi Rasika,

I didn’t test with IE, but maybe your problems are linked with this post :!/thread/8675979

Hi Koenraad,

I am facing the same task, but I cannot make it work so far.

In contrast to your proposal I thought it might be clever to extend the Button after the click of the user, than click again ( to download the files and remove afterwards the extensions.

public void buttonClick(ClickEvent event) {
if (!this.isButtonStateDownload) {
this.isButtonStateDownload = true;
// extend Button and click again

        while (event.getButton().getExtensions().iterator().hasNext()) {
            Extension myExtension = event.getButton().getExtensions().iterator().next();

        this.isButtonStateDownload = false;

[/code]My Problem is, that removing the extensions lead by your proposal to a ConcurrentModificationException. With the code above it runs, but it does not export the files anymore (probably, because the FileDownloader is not yet ready?). It works fine when not trying to remove the extensions, but I do not think, that this is a good solution.

The reason why not extending in advance is, that I use checkboxes to select which files should me exported, but I use them also with a delete button and it might be quite annoying if a click takes to long although the user only wants to delete these files but not download them.

Any suggestions how to deal with that?

Thank you