开发者

Rendering a PDF in a Grails Web Flow end state

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"开发者_C百科).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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜