I was asking the same question not long ago. Here is an easy way to return a pdf from an
action method (in this case a Jasper Report):
| byte[] data = JasperRunManager.runReportToPdf(compileDir
| + report.getReport() + ".jasper", params);
|
| FacesContext facesContext = FacesContext.getCurrentInstance();
| HttpServletResponse response = (HttpServletResponse) facesContext
| .getExternalContext().getResponse();
| response.setContentType("application/pdf");
| response.setContentLength(data.length);
| response.setHeader("Content-disposition",
| "attachment;filename=report.pdf");
|
| try {
|
| OutputStream out = response.getOutputStream();
|
| out.write(data);
|
| out.flush();
| out.close();
|
| facesContext.responseComplete();
| } catch (IOException ex) {
| FacesMessages.instance().add(
| "Error while downloading the file: report.pdf");
| }
|
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4090891#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...