« Return to Thread: problem on clicking the Print button twice
Hi,
In my application , I had a "Print" button in one of the screen . On clicking it, a pdf is opening in the browser. every thing is fine.
Now, if I click again the same "Print" button on the screen , a pdf is not opening but my application screen is displaying again in a new brower.
this is the piece of code which I am using it.:
I might have missed out to set some properties for the response i believe .
any suggestions would be helpful.
**********************************
FacesContext context = FacesContext.getCurrentInstance();
PDFGenerator pdfGenerator = new PDFGenerator();
try
{
if (!context.getResponseComplete())
{
Object response = context.getExternalContext().getResponse();
if (response instanceof HttpServletResponse)
{
HttpServletResponse res = (HttpServletResponse)response;
Document document = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(document, baos);
document.open();
if (pdfGenerator.generatorPDF(document,
cicpsPDFTableTOList))
{
document.close();
res.setContentType("application/pdf");
res.setHeader("Cache-Control", "no-cache");
res.setContentLength(baos.size());
ServletOutputStream out = res.getOutputStream();
baos.writeTo(out);
out.flush();
context.responseComplete();
}
else
{
addMessage("No matches found.");
document.close();
}
}
}
}
**********************************
Environment:
--------------
iText 1.4.4
JSF
weblogic 9
thanks,
with regards,
Srinivasa.
« Return to Thread: problem on clicking the Print button twice
| Free embeddable forum powered by Nabble | Forum Help |