DownloadLink is nice and handy for creating a button/link for downloading a file, along these lines:
add(new DownloadLink("downloadButton", getReportFile(), "report.pdf"));
and
<input type="button" wicket:id="downloadButton" value="Download" />
However, I would like to trigger the generation of the file to download only when the button/link is clicked. In other words, upon click, I'd call a method that generates the file (a Pentaho report in our case), puts it in a temp place and returns a File pointing to it. Then I'd tell the DownloadLink to use that File. Question is, is this possible somehow? 
Currently we have something like the code below, which works, but I'm interested in whether DownloadLink could be used instead.
add(new Link<Void>("downloadButton") {
  @Override
  public void onClick() {
    IResourceStream resourceStream = new AbstractResourceStreamWriter() {
      @Override 
      public void write(OutputStream output) {
        try {
          reportService.generateReport(output, report);
        } catch (IOException e) {
          // ...
        }
      }
      @Override
      public String getContentType() {                        
        return CONTENT_TYPE_PDF;
      }
    };
    getRequestCycle()
      .setRequestTarget(new ResourceStreamRequestTarget(resourceStream)
      .setFileName("report.pdf"));
  }
});
(Wicket 1.4.18, if it makes a difference.)