Jun 21st, 2012, 09:14 AM
MVC: controller to AbstractPdfView and going BACK?
I have a controller creating a ModelAndView. In the model view I have set an implementation of AbstractPdfView.
This works all fine and the open/save dialog appears for the PDF file.
But how can I return back to the controller respectively create a new ModelAndView so that a new page after the dialog appears?
Jun 21st, 2012, 09:32 AM
You cannot... The response is already send to the client and you cannot send another response.
Jun 22nd, 2012, 04:02 AM
Yes I read the guide - not the latest one, but on 3.0.7 since we are working on that one.
Would the AbstractWizardFormController the proper approach? I see this is deprecated and there is only the @Controller annotation. So if there is now other possibilities I will give this a try.
Jun 27th, 2012, 04:59 AM
AbstractWizardFormController using Annotated @Controllers
I found these links regarding wizard workflow using the Controller annotation:
Unfortunately for my use case this doesn't help since in one of my view it returns a ModelAndView with an AbstractPdfView added.
Once the PdfView (open/save dialog) appears it does not return back to the workflow allowing to show my next view .
It seems there is no solution for that and the user has no manually go to the next page? Or in my case to refresh the current page?
Jun 27th, 2012, 10:57 AM
PDF write logic in Controller instead of AbstractView/AbstractWizardFormController
Ok. I moved away from using AbstractView and AbstractWizardFormController since I can put the PDF download logic also in the Controller.
Though some things needs to be considered:
- it is only allowed to use the writer. Because later WebSphere complains an "OutputStream already obtained" because it uses the writer and my controller uses the outputstream. And both are not allowed to be used in the same request and response.
- in the meanwhile I use the writer (which of course doesn't make sense since I have to write bytes/PDF) to check whether the application can deal with my normal ModelAndView (for refreshing current page) while the PDF dialog appears.
The open/save dialog appears but the view is not updated?!
Jul 4th, 2012, 04:41 AM
I have managed to solve by a working in my JSP page. Basically:
First: Controller's print method updates the view and set a flag in the command
Second: JSP checks flag in the command and triggers a form to show the controller's print dialog
So the second step is always performed when the view is displayed and triggers to the controller to show the print dialog. The PDF itself is stored in the session.
So far this is the only solution I know of. Hope this helps in case others are running into it.