Hello, I have a Dialog with Button called “Download”, and I want on user click on this button start a file downloading.
so…
// the button
Button downloadButton = new Button("Download");
// file data
byte[] data = getContent();
// stream resource
StreamResource streamResource = new StreamResource("fileName.extName", () -> new ByteArrayInputStream(data));
downloadButton.addClickListener(event -> {
// ????
});
All examples I found in Google related to Vaadin 7 or Vaadin 8 with classes like FileDownloader or something like that: Page.getCurrent().open(…);
This classes missing in Vaadin 12.
Maybe I need wrap my button with anchor or vice-versa, I don’t know, help me please. I need a button, on click browser must start file download and do not break the current page.
Thank you in advance, %username%!