Hi all, I'm having the following problem: I've built a form in which I let the user fill in a lot of data. At the end of the form, I present a button that renders a 'pdf' of the form.
I use the submit funtionality like this: <xforms:submission id = "print-pdf-submission" ref = "instance('form-instance')/formcontent"
xxforms:show-progress = "false" method = "post" action = "/e-formulieren/pdf" replace = "all">
The action point to a xpl that directs to a custom processor, that creates a pdf and returns the bytearray back to the outputstream of the response, like this: ExternalContext externalContext = (ExternalContext) context
.getAttribute(org.orbeon.oxf.pipeline.api.PipelineContext.EXTERNAL_CONTEXT); ExternalContext.Response response = externalContext.getResponse(); response.setContentType("application/pdf");
OutputStream out = response.getOutputStream(); out.flush(); // build PDF PDFBuilder pdfBuilder = (PDFBuilder) CustomOverviewBuilderFactory.getOverviewBuilder(OverviewProperties.PROP_PDF_BUILDER);
ByteArrayOutputStream pdf = (ByteArrayOutputStream) pdfBuilder.buildOverview(inputDocument); // write the pdf out.write(pdf.toByteArray()); This works great, but I experience the following things: - in IE (8), hitting the pdf button results in showing the pdf file, but when I hit the back button of the browser, I am directed to the page that was active before the form. So, I loose the form! And all data of course... just by wanting the see the form in a pdf format.
- in Firefox (3.6) all works fine... hitting the back button when the pdf is loaded in the browser, loads the form again with all data filled in. So, I think I change the submission to:
<xforms:submission id = "print-pdf-submission" ref = "instance('form-instance')/formcontent" xxforms:show-progress = "false"
method = "post" action = "/e-formulieren/pdf" replace = "all" xxforms:target = "_blank">
this way, the pdf form tries to open in a new window. I cannot rely on the user having the pop-up blocker turned off, so I turn on mine and now I experience the following things:
- in Firefox, I get a javascript error message! See the jpg I attached... Clicking this error message away, allowing pop-ups and retry to ope the pdf works fine... but I have to click the error message away, which is not good :-(
- in IE (8), the pop-up blocker also nicely catches the try to open the pdf (no javascript error message), but when I allow the pop-ups, IE refreshes I form! And all data is gone! Well, here come the questions:
- is there anybody around that experienced the same thing(s) with pop-up blocking? - is there anybody around that experienced the same thing(s) with page refreshing when you don't want to? or maybe even more helpful: - is there anybody around that built a form that delivers the functionality to view the form in a pdf and solved the problem I experience? For answering this with yes, please take into account that I really need to build the pdf with a java class, so a custom processor, that puts the pdf back on the response. Or can this be done otherwise??
Anybody having ideas? Best regards, Bart Ottenkamp
-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws firefox_error.jpg (205K) Download Attachment |
Bart,
You are hitting on "interesting" issues: 1. back button handling 2. popup blockers On #1, we do have code to handle the back button, but it seems that this is not working properly with IE 8. So that would be a bug on our side I guess. If instead of clicking on your PDF button, instead you enter in your URL bar e.g. www.google.com and then do a browser back, do you have the same issue? On #2, yeah hitting the popup blocker is hard to recover from. And unfortunately browsers are not smart enough to notice that the opening of the new window is a consequence of a user action when there is an Ajax request inserted in the middle. So in that case, you would have instead to: * store the resulting PDF file into e.g. your user session, preferably with a unique id so that multiple PDF generations can occur in a user session without conflict * load that PDF through a GET URL, with xforms:load or xforms:submission[@method = 'get'] That's not ideal either because that raises the question of delivering transient data which really would be best delivered with a POST, and what you do with the data stored in the session after it has been delivered to the client. -Erik On Mon, Feb 22, 2010 at 2:42 AM, Bart Ottenkamp <[hidden email]> wrote: > Hi all, > I'm having the following problem: > I've built a form in which I let the user fill in a lot of data. At the end > of the form, I present a button that renders a 'pdf' of the form. > I use the submit funtionality like this: > <xforms:submission > id = "print-pdf-submission" > ref = "instance('form-instance')/formcontent" > xxforms:show-progress = "false" > method = "post" > action = "/e-formulieren/pdf" > replace = "all"> > The action point to a xpl that directs to a custom processor, that creates a > pdf and returns the bytearray back to the outputstream of the response, like > this: > ExternalContext externalContext = (ExternalContext) context > > .getAttribute(org.orbeon.oxf.pipeline.api.PipelineContext.EXTERNAL_CONTEXT); > ExternalContext.Response response = > externalContext.getResponse(); > response.setContentType("application/pdf"); > OutputStream out = response.getOutputStream(); > out.flush(); > // build PDF > PDFBuilder pdfBuilder = (PDFBuilder) > CustomOverviewBuilderFactory.getOverviewBuilder(OverviewProperties.PROP_PDF_BUILDER); > ByteArrayOutputStream pdf = (ByteArrayOutputStream) > pdfBuilder.buildOverview(inputDocument); > // write the pdf > out.write(pdf.toByteArray()); > This works great, but I experience the following things: > - in IE (8), hitting the pdf button results in showing the pdf file, but > when I hit the back button of the browser, I am directed to the page that > was active before the form. So, I loose the form! And all data of course... > just by wanting the see the form in a pdf format. > - in Firefox (3.6) all works fine... hitting the back button when the pdf is > loaded in the browser, loads the form again with all data filled in. > So, I think I change the submission to: > <xforms:submission > id = "print-pdf-submission" > ref = "instance('form-instance')/formcontent" > xxforms:show-progress = "false" > method = "post" > action = "/e-formulieren/pdf" > replace = "all" > xxforms:target = "_blank"> > this way, the pdf form tries to open in a new window. I cannot rely on the > user having the pop-up blocker turned off, so I turn on mine and now I > experience the following things: > - in Firefox, I get a javascript error message! See the jpg I attached... > Clicking this error message away, allowing pop-ups and retry to ope the pdf > works fine... but I have to click the error message away, which is not good > :-( > - in IE (8), the pop-up blocker also nicely catches the try to open the pdf > (no javascript error message), but when I allow the pop-ups, IE refreshes I > form! And all data is gone! > Well, here come the questions: > - is there anybody around that experienced the same thing(s) with pop-up > blocking? > - is there anybody around that experienced the same thing(s) with page > refreshing when you don't want to? > or maybe even more helpful: > - is there anybody around that built a form that delivers the functionality > to view the form in a pdf and solved the problem I experience? For answering > this with yes, please take into account that I really need to build the pdf > with a java class, so a custom processor, that puts the pdf back on the > response. Or can this be done otherwise?? > Anybody having ideas? > Best regards, > Bart Ottenkamp > > -- > You receive this message as a subscriber of the [hidden email] mailing > list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > > -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Free forum by Nabble | Edit this page |