You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Stefan Lindner <li...@visionet.de> on 2009/04/09 09:39:55 UTC

Montable PDF creating page

I need some trick to turn the response into a PDF stream. E. g. I have a
Bookmarkable Page PdfPAge

	public class PdfPage extends WebPage {
	
		public PdfPage (final PageParameters parameters) {
			// Respond with PDF content.
		}
	}


	Application.init() {
		mountBookmarkablePage("/PdfGenerator", PdfPage.class);

Is it possible to let a WebPage create a pdfOutput? If I try to do the
following

		Response r = getResponse();
		if (r instanceof WebResponse) {
			WebResponse wr = (WebResponse)r;
			wr.reset();
			OutputStream os = wr.getOutputStream();
			try {
				os.write(/*PDFcontent*/);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

I can see the Exception java.lang.IllegalStateException:
getOutputStream() has already been called for this response

The reason for this is: I did not find something like
BookmarkableResource in wicket. It is no problem to have a
DynaicResourceLink in a page but the displayes content is not
bookmarkable. Any Ideas?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: Montable PDF creating page

Posted by Stefan Lindner <li...@visionet.de>.
Thanks Igor! Works fine!

-----Ursprüngliche Nachricht-----
Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Gesendet: Donnerstag, 9. April 2009 18:09
An: users@wicket.apache.org
Betreff: Re: Montable PDF creating page

why would you want a mounted page to create pdfs? servlets are so much
better at that.

that said you can do

getrequestcycle().setrequesttarget(new sometargetthatstreamspdfs());
throw new restartresponseexception();

-igor

On Thu, Apr 9, 2009 at 12:39 AM, Stefan Lindner <li...@visionet.de> wrote:
> I need some trick to turn the response into a PDF stream. E. g. I have a
> Bookmarkable Page PdfPAge
>
>        public class PdfPage extends WebPage {
>
>                public PdfPage (final PageParameters parameters) {
>                        // Respond with PDF content.
>                }
>        }
>
>
>        Application.init() {
>                mountBookmarkablePage("/PdfGenerator", PdfPage.class);
>
> Is it possible to let a WebPage create a pdfOutput? If I try to do the
> following
>
>                Response r = getResponse();
>                if (r instanceof WebResponse) {
>                        WebResponse wr = (WebResponse)r;
>                        wr.reset();
>                        OutputStream os = wr.getOutputStream();
>                        try {
>                                os.write(/*PDFcontent*/);
>                        } catch (Exception e) {
>                                e.printStackTrace();
>                        }
>                }
>        }
>
> I can see the Exception java.lang.IllegalStateException:
> getOutputStream() has already been called for this response
>
> The reason for this is: I did not find something like
> BookmarkableResource in wicket. It is no problem to have a
> DynaicResourceLink in a page but the displayes content is not
> bookmarkable. Any Ideas?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Montable PDF creating page

Posted by Igor Vaynberg <ig...@gmail.com>.
why would you want a mounted page to create pdfs? servlets are so much
better at that.

that said you can do

getrequestcycle().setrequesttarget(new sometargetthatstreamspdfs());
throw new restartresponseexception();

-igor

On Thu, Apr 9, 2009 at 12:39 AM, Stefan Lindner <li...@visionet.de> wrote:
> I need some trick to turn the response into a PDF stream. E. g. I have a
> Bookmarkable Page PdfPAge
>
>        public class PdfPage extends WebPage {
>
>                public PdfPage (final PageParameters parameters) {
>                        // Respond with PDF content.
>                }
>        }
>
>
>        Application.init() {
>                mountBookmarkablePage("/PdfGenerator", PdfPage.class);
>
> Is it possible to let a WebPage create a pdfOutput? If I try to do the
> following
>
>                Response r = getResponse();
>                if (r instanceof WebResponse) {
>                        WebResponse wr = (WebResponse)r;
>                        wr.reset();
>                        OutputStream os = wr.getOutputStream();
>                        try {
>                                os.write(/*PDFcontent*/);
>                        } catch (Exception e) {
>                                e.printStackTrace();
>                        }
>                }
>        }
>
> I can see the Exception java.lang.IllegalStateException:
> getOutputStream() has already been called for this response
>
> The reason for this is: I did not find something like
> BookmarkableResource in wicket. It is no problem to have a
> DynaicResourceLink in a page but the displayes content is not
> bookmarkable. Any Ideas?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org