Starting with version 3.1.0, Grid Exporter Add-on introduces new DownloadHandler-based methods to replace the deprecated StreamResource methods. This migration is necessary for forward compatibility: as of Vaadin 25, StreamResource is deprecated and marked for removal, and it will be removed in a future Vaadin release.
The Grid Exporter Add-on now provides two sets of methods:
- Old API (Deprecated): Methods returning
StreamResourceorGridExporterStreamResource - New API (Recommended): Methods returning
DownloadHandler
✅ Your existing code will continue to work! The old methods are deprecated but still functional. You can migrate at your own pace.
The new DownloadHandler API requires Vaadin 24.8.0 or later.
pom.xml:
<properties>
<vaadin.version>24.8.0</vaadin.version>
</properties>Replace the deprecated get*StreamResource() methods with the new get*DownloadHandler() methods.
Before:
Anchor excelLink = new Anchor("", FontAwesome.Regular.FILE_EXCEL.create());
excelLink.setHref(exporter.getExcelStreamResource());
excelLink.getElement().setAttribute("download", true);After:
Anchor excelLink = new Anchor("", FontAwesome.Regular.FILE_EXCEL.create());
excelLink.setHref(exporter.getExcelDownloadHandler());
excelLink.getElement().setAttribute("download", true);Before:
exporter.getDocxStreamResource()
exporter.getDocxStreamResource(customTemplate)After:
exporter.getDocxDownloadHandler()
exporter.getDocxDownloadHandler(customTemplate)Before:
exporter.getPdfStreamResource()
exporter.getPdfStreamResource(customTemplate)After:
exporter.getPdfDownloadHandler()
exporter.getPdfDownloadHandler(customTemplate)Before:
exporter.getCsvStreamResource()After:
exporter.getCsvDownloadHandler()If you're creating custom export links instead of using auto-attached buttons:
Before:
GridExporter<Person> exporter = GridExporter.createFor(grid);
exporter.setAutoAttachExportButtons(false);
Anchor customLink = new Anchor("", "Download Excel");
customLink.setHref(exporter.getExcelStreamResource().forComponent(customLink));After:
GridExporter<Person> exporter = GridExporter.createFor(grid);
exporter.setAutoAttachExportButtons(false);
Anchor customLink = new Anchor("", "Download Excel");
customLink.setHref(exporter.getExcelDownloadHandler().forComponent(customLink));Note:
forComponent(...)is optional. It binds the download to a component so that the component is automatically disabled while the export runs (whensetDisableOnClick(true)is enabled). If you don't need that behavior, you can omit it:customLink.setHref(exporter.getExcelDownloadHandler());
| Old Method (Deprecated) | New Method | Notes |
|---|---|---|
getExcelStreamResource() |
getExcelDownloadHandler() |
Excel export |
getExcelStreamResource(String) |
getExcelDownloadHandler(String) |
Excel with template |
getDocxStreamResource() |
getDocxDownloadHandler() |
DOCX export |
getDocxStreamResource(String) |
getDocxDownloadHandler(String) |
DOCX with template |
getPdfStreamResource() |
getPdfDownloadHandler() |
PDF export |
getPdfStreamResource(String) |
getPdfDownloadHandler(String) |
PDF with template |
getCsvStreamResource() |
getCsvDownloadHandler() |
CSV export |
All existing features continue to work with the new API:
- ✅ Concurrent download control
- ✅ Download timeouts
- ✅ Button disable/enable during download
- ✅ Custom templates
- ✅ All export formats (Excel, DOCX, PDF, CSV)
- ✅ Custom columns and headers
- ✅ Hierarchical data support
- Version 3.1.0: New
DownloadHandlermethods introduced, old methods deprecated - A future release: Old
StreamResourcemethods will be removed
If you encounter any issues during migration, please:
- Check that you're using Vaadin 24.8.0 or later
- Review the deprecation warnings in your IDE
- Open an issue on GitHub
Before (Version 3.0.x):
Grid<Person> grid = new Grid<>(Person.class);
grid.setItems(people);
GridExporter<Person> exporter = GridExporter.createFor(grid);
// Auto-attached buttons use StreamResource internallyAfter (Version 3.1.0+):
Grid<Person> grid = new Grid<>(Person.class);
grid.setItems(people);
GridExporter<Person> exporter = GridExporter.createFor(grid);
// Auto-attached buttons now use DownloadHandler internally
// No code changes needed if using auto-attached buttons!Custom Implementation:
Grid<Person> grid = new Grid<>(Person.class);
grid.setItems(people);
GridExporter<Person> exporter = GridExporter.createFor(grid);
exporter.setAutoAttachExportButtons(false);
// Create custom export buttons
Anchor excelBtn = new Anchor("", "Excel");
excelBtn.setHref(exporter.getExcelDownloadHandler());
excelBtn.getElement().setAttribute("download", true);
Anchor pdfBtn = new Anchor("", "PDF");
pdfBtn.setHref(exporter.getPdfDownloadHandler());
pdfBtn.getElement().setAttribute("download", true);
add(excelBtn, pdfBtn);