Our website was recently rewritten in the Play framework. We offer file downloads to users, and files download correctly using renderBinary().
Now I’d like to display/render a new html page to the user while the binary file downloads in the background. Sort of like this:
[Dear website user: Click here to download this file: bigfile.zip]
After the user clicks, bigfile.zip begins downloading. Then I want to show user a new page:
[Dear website user: Thanks for downloading bigfile. Here is some additional information.]
Calls to renderBinary() never return, so I can’t call something like Application.showMyPage() afterwards. Similarly, a call to render my html page [Application.showMyPage()] never returns either, so I can’t call renderBinary() after.
Maybe a javascript onclick is the only way to do it, but I’d love to know if there’s a clean way to do it in Play.
What you are asking is for your client side to perform two simultaneous requests, which isn’t how HTTP works. The easiest way, and the way that I see download sites work, is as follows
renderBinarymethod.It is a user experience that people are generally expecting.