This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

Vaadin and generic downloads in Portlets

Do you use a Vaadin application as portlet with e.g. Liferay and does your application create generic downloads (e.g. reports)?

If you want to download generic/dynamically created files from a portlet, you don't have too many options. You could use the FileDownloader extension or you could open a new window with the file resource. But both options are not perfect. The FileDownloader has to be connected to a clickable component e.g. a button and the new window won't be closed automatically (browser dependent). The FileDownloader is a good solution (see recommendations) but it triggers the download from the browser via user interaction. If you have dynamic UIs or if you can't use a FileDownloader because you need a more generic solution, then you could have a problem?

Our JVx Vaadin UI implementation is very dynamic and a developer doesn't use native vaadin components (until he needs to do). The FileDownloader didn't work for us because of UI abstraction. But we have a solution that might help you as well. Its comparable to FileDownloader but it's not user driven.

Simply use our extension with your UI:

//only once in init
DownloaderExtension downloader = new DownloaderExtension();
downloader.extend(this);

//start the download
downloader.setDownloadResource(resource);

The extension is not limited to UI but one Downloader per application is enough.

The source code is available in our repository.