Announcement Announcement Module
Collapse
No announcement yet.
MVC: controller to AbstractPdfView and going BACK? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MVC: controller to AbstractPdfView and going BACK?

    Hi,

    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?

    Thanks Tai

  • #2
    You cannot... The response is already send to the client and you cannot send another response.

    Comment


    • #3
      AbstractWizardFormController?

      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.

      Thanks Tai

      Comment


      • #4
        AbstractWizardFormController using Annotated @Controllers

        I found these links regarding wizard workflow using the Controller annotation:

        http://stackoverflow.com/questions/4...ed-controllers
        http://gablog.eu/online/node/89.html

        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?

        Hmm...

        Comment


        • #5
          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?!

          Comment


          • #6
            Workaround solution

            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.

            Comment

            Working...
            X