Hi Olli,
thanks for the add-on. It works, but the first time, I click the download button, nothing is downloaded. From the second click it works perfectly.
Here is the code:
Button downloadDataButton = new Button("Download data");
downloadDataButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
downloadDataButton.addClickListener(event -> {
FileDownloadWrapper buttonWrapper = new FileDownloadWrapper(
new StreamResource("ResultDataFor" + queryName + ".xlsx", () -> {
return new ByteArrayInputStream(service.createDataDownloadFile(queryName));
})
);
buttonWrapper.wrapComponent(downloadDataButton);
dataDownloadLayout.add(buttonWrapper);
});
dataDownloadLayout.add(info, downloadDataButton);
I debugged the code and can see that the first time I press the button, nothing is returned, but without error. It seems the code is ignored. Maybe the initialization of the FileDownloadwrapper is wrong? What is wrong?