0

I have a simple thymeleaf form with a drop down as report type and a button to generate the selected report. I need to provide the Save As/Open window of the browser, so the user can see the report.

The result of the report execution could be

A/ the report itself. In this case I need to provide a HttpServletResponse.

B/ the report is empty. In this case I need to reload the view with a Model attribute showing a message to the user.

C/ any kind of error during report generation. In this case I log the error, and reload the view with slightly different message informing the user about the issue. This is also managed with Model attribute.

While the report is generating I hide the Generate button and show a progress bar.

As of now I make form submission. It works well, when there is B or C. But in A I don't know how to catch up that the submission is finished. So, I can show the button and hide the progress bar.

pillesoft
  • 460
  • 1
  • 5
  • 16

1 Answers1

0

At the end of the report generation, you can provide a link on the HTML page that will redirect to an endpoint that returns a ResponseEntity with an InputStreamResource body (See Return a stream with Spring MVC's ResponseEntity for details)

Wim Deblauwe
  • 19,439
  • 13
  • 111
  • 173
  • Yes, but in this case the user has to click twice. I want the save as dialog automatically displayed when the report is ready. But the UI must be refreshed as well. – pillesoft Jan 10 '20 at 19:09