I would like to build a results page for a report export page. This results page must display the status of the export and offer the download of this export.

The export is done in an action method. I can execute it via a commandButton but it must be executed automatically on load.

How can I accomplish this?

JSF:

<h:commandButton value="Download report" action="#{resultsView.downloadReport}"/>

Backing bean:

  public String downloadReport() {
    ...
    FileDownloadUtil.downloadContent(tmpReport, REPORT_FILENAME);
    // Stay on this page
    return null;
  }

Clarification: Is this feasible with a4j? I thought of a solution that an Ajax request triggers my downloadReport action and its request is the file download.

Edit
Report