How to detect when Vaadin FileDownloader succeeds or fails

前端 未结 1 1248
攒了一身酷
攒了一身酷 2021-01-06 05:21

I have Vaadin 7 code to give the user an option to download a file:

    Button btnDownloadResults = new Button(\"Download Results\", FontAwesome.CLOUD_DOWNLO         


        
相关标签:
1条回答
  • 2021-01-06 05:57

    After more research I believe the answer is that there is no simple way to get this information from the FileDownloader.

    The difficulty appears to be a consequence of the way the FileDownloader is designed. From the FileDownloader docs: "Download should be started directly when the user clicks e.g. a Button without going through a server-side click listener to avoid triggering security warnings in some browsers."

    Because there is no round-trip back to the web server, there is no place to respond when the download fails, starts, or succeeds.

    Some vague (and possibly bad) ideas for a workaround:

    • Have JS post some kind of asynchronous notification to the web server, letting it know what happened. (Using JMS or Ajax?)
    • If there was some kind active process on the backend involved with transferring the file, it would know when the transfer happened.

    But the short answer seems to be there is no built-in way in Vaadin to do it.

    0 讨论(0)
提交回复
热议问题