2012-01-14 13:41, csckid:
> I have submit button named savePrescription. What I want is when this button
> is clicked it would save the data then return the pdf file via stream
> response and redirect to a page. 
> So far I was able to save the data and return the pdf in target="_blank" but
> I don't know how would I redirect the existing page into another page.
> 
> 
> I tried the following: this redirects but doesn't open the stream response.
> StreamResponse onSuccessFromSavePrescription() {
>                         //savedata
>                         response.sendRedirect("index");
>                       InputStream is = prescriptionPdf.pdfGeneration(patient, 
> visit);
>                       return new 
> PDFStreamResponse(is,"Prescription-"+visit.getId());
>                       
> }

You cannot send a PDF and a HTML page in one HTTP response.

What you have to do is send a page containing a JS that opens a browser
window with the link to the PDF.

Object onSuccessFromSavePrescription() {
  // savedata
  return AnotherPage.class;
}

In AnotherPage:

void beforeRender() {
  String linkUrl = componentResources
    .createEventLink("showPdf").toURI();
  jsSupport.addScript("window.open('%s')", linkUrl);
}

StreamResponse onShowPdf() {
  InputStream is = prescriptionPdf.pdfGeneration(patient, visit);
  return new PDFStreamResponse(is,"Prescription-"+visit.getId());
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to