Thanks for reading my post. In my Vaadin8-Application, I use a Viritin-DownloadButton to allow the user to generate and download a report.
The button is very useful, but - unlike my other buttons - it cannot be clicked via a shortcut or programmatically. Only by focusing it and pressing enter or by actually clicking it with the mouse can I start a download.
DownloadButton pdfButton = new DownloadButton();
//[...]
pdfButton.setClickShortcut(KeyCode.P); //Doesn't work...
//[...]
pdfButton.click();//Does not work
This applies to Viritin 2.5 and 2.9. Do you folks have any idea why that might be? And do you know of any ways to trigger the download programmatically? I need that in an eventListener of a Grid, where a doubleclick is supposed to start the download.
Downloads can only be started directly as a result of a user action because of browser security restrictions. This means that if you have a server-side event listener reacting to something, the download action is disconnected from the original user event and thus blocked by the browser. You’d need to write the event handler entirely in JavaScript to make it work.