What's the easiest way to implement background downloading in Wicket?
- by David Moles
I've got a simple Wicket form that lets users select some data and then download a ZIP file (generated on the fly) containing what they asked for. Currently the form button's onSubmit() method looks something like this:
public void onSubmit() {
IResourceStream stream = /* assemble the data they asked for ... */ ;
ResourceStreamRequestTarget target = new ResourceStreamRequestTarget(stream);
target.setFileName("download.zip");
RequestCycle.get().setRequestTarget(target);
}
This works, but of course the request stops there and it's impossible to display any other feedback to the user.
What I'd like to have is something like the typical "Your requested download [NAME] should begin automatically. If not, click this link." Ideally, still displaying the same page, so the user can immediately select some different data and download that as well.
I imagine it's possible to do this using Wicket's Ajax classes, but I've managed to avoid having to use them so far, and it's not immediately obvious to me how. What's my quickest way out, here?