You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If createInputStream fails, it's not possible to intercept the exception and handle it.
Moreover, if setDisableOnClick is set, the button will remain disabled (because no DownloadStartsEvent will occur).
As a workaround, one need to write error handling logic inside of the InputStreamFactory:
btnDownload = new LazyDownloadButton("Download",
() -> "foo.pdf",
() -> {
try {
return new ByteArrayInputStream(generateFile());
} catch (RuntimeException e) {
btnDownload.getUI().ifPresent(ui->ui.access(()->{
// restore normal state, so that the user can download the content again
btnDownload.setText("Download");
btnDownload.setEnabled(true);
Notification.show("Download failed").addThemeVariants(NotificationVariant.LUMO_ERROR);
}));
throw e;
}
});
The text was updated successfully, but these errors were encountered:
If
createInputStream
fails, it's not possible to intercept the exception and handle it.Moreover, if
setDisableOnClick
is set, the button will remain disabled (because noDownloadStartsEvent
will occur).vaadin-lazy-download-button/addon/src/main/java/org/vaadin/stefan/LazyDownloadButton.java
Lines 114 to 128 in 5292c53
As a workaround, one need to write error handling logic inside of the
InputStreamFactory
:The text was updated successfully, but these errors were encountered: