I’m trying to figure out which would be the best approach to get a file downloaded from a table context menu, or in other words how to start a download programmatically without the user’s click event. I understand the FileDownloader Vaadin behaviour but I can’t use this way because the context menu is filled by Action objects. I have an implementation that makes the job using
UI.getCurrent().getPage().open(resource, null, false); to open the file on the browser and to trigger the download. But this method
Page.open with a Resource as argument is deprecated and now we should use the
Page.open with an URL as argument. My problem is that the file is not hosted on the web server so I cannot provide a valid URL to the file. It has to be the server who prepares the file. If the good approach it’s to create a temporary file on the web server (BTW I would like to avoid that), does Vaadin have something headed to manage temp files?
I don’t think there is currently a proper way to achieve this. I personally still use the deprecated method until there is a right way to do this in such a case.
Ok, Thanks!
By the way, using this approach (deprecated method) Have you been able to download .pdf files without that the browser’s plugin opens the file? (just a download as it happens with the rest of types of file)
I know FileDownloader plays with the Content/Disposition parameter on the servlet response but I don’t see how to do that by myself with the Page class.