Results 1 to 6 of 6

Thread: MVC: controller to AbstractPdfView and going BACK?

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Location
    Zurich, Switzerland - Freiburg i. Breisgau, Germany
    Posts
    102

    Question 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
    Tai Truong
    pointsoftware.ch

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    You cannot... The response is already send to the client and you cannot send another response.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jun 2008
    Location
    Zurich, Switzerland - Freiburg i. Breisgau, Germany
    Posts
    102

    Question 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
    Tai Truong
    pointsoftware.ch

  4. #4
    Join Date
    Jun 2008
    Location
    Zurich, Switzerland - Freiburg i. Breisgau, Germany
    Posts
    102

    Unhappy 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...
    Tai Truong
    pointsoftware.ch

  5. #5
    Join Date
    Jun 2008
    Location
    Zurich, Switzerland - Freiburg i. Breisgau, Germany
    Posts
    102

    Question 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?!
    Tai Truong
    pointsoftware.ch

  6. #6
    Join Date
    Jun 2008
    Location
    Zurich, Switzerland - Freiburg i. Breisgau, Germany
    Posts
    102

    Lightbulb 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.
    Tai Truong
    pointsoftware.ch

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •