Hi, I am trying to use the DynamicFileDownloader in a context menu but instead of the intended content it downloads the html content of the page.
Do you think it will just not work in a context menu? Or is there a way to fix it?
I used a very simple code:
TextArea textArea = = new TextArea(); textArea.setSizeFull(); addAndExpand(textArea);ContextMenu contextMenu = new ContextMenu(textArea);
DynamicFileDownloader dynamicFileDownloader = new DynamicFileDownloader(“Download”, null, outputStream -> {
try {
outputStream.write(textArea.getValue().getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}) {
@Override
protected String getFileName(VaadinSession session, VaadinRequest request) {
return LocalDateTime.now() + “foobar.txt”;
}
};
contextMenu.addItem(dynamicFileDownloader);