Using FileDownloader without a button

I want to use the FileDownloader of Vaadin without extending a Button. The final result should be that the user clicks on an entry of a table, and that should then trigger the download.

With the FileDownloader it works fine, but it seems like you need to extend a Button to make this work. Here is the code so far if it helps:

table.addItemClickListener(new ItemClickListener()    {
            public void itemClick(ItemClickEvent event) {
                Map<String, Object> dok = dbService.getDokument(event.getItem().getItemProperty("Id").getValue().toString());
                
                myResource = createResource(dok);
                fileDownloader = new FileDownloader(myResource);
                //TODO finish File download
                //fileDownloader.extend(ta);
            }
        });   

private StreamResource createResource(Map<String, Object> dok) {
        return new StreamResource(new StreamSource() {
            @Override
            public InputStream getStream() {
                byte[] file = (byte[]
) dok.get("DATA");
                
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                bos.write(file, 0, file.length);
                return new ByteArrayInputStream(bos.toByteArray());

            }
        }, getValue(dok.get("DOK_NAME")));
    }

Hi Tobias,

The FileDownloader can extend any AbstractComponent from the Vaadin framework, so it does not have to be strictly a button. One approach could be to provide the table entries as components (as defined in the
documentation
) and then extend those with the file downloader.

Hope this helps,
Goran