views:

40

answers:

1

I am using the Rendering plugin to generate a PDF from within a Web Flow. The problem is that I cannot get my end state to return the PDF response. If I call:

renderPdf(template: "/letter/generate/createpdf", model: [letter: flow.letter], filename: 'doc.pdf')

From within my end state action, it still tries to return an end state view. I can, however, put this in something like:

createpdf {
    action {
        renderPdf(template: "/letter/generate/createpdf", model: [letter: flow.letter], filename: 'doc.pdf')
        return
    }
    on("success").to "finish"
}

But then of course I get a:

java.lang.IllegalStateException: getOutputStream() has already been called for this response

I basically want my end state to return the PDF file. Any ideas?

A: 

I'm assuming this functionality works if it's not within the context of a web flow. I've also noticed that some things don't work quite as I expect on the end state of a web flow. I'm not clear exactly why that is, but when I've encountered situations like this I have typically resorted to handling it with a redirect to another action. So essentially just pass your flow.letter as a param to another action outside of the webflow; that approach has fixed a number of webflow related problems for me. Unfortunately I don't have access to my code at the moment, because I seem to recall some nuances around parameters staying in scope when using a redirect at the end of a webflow. If you run into problems post them here and I'll take a look.

proflux
Thanks for the tip. That's exactly the problem I am having now -- getting my Letter object out of the flow
UltraVi01