-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi I want open a jasperreport output file generated in new Window of browser
Im trying:
Executions.getCurrent().sendRedirect("the_url_generated_of_report","_blank");
but I can not found a method that returns me the url of output file generated by Jasper
Exists anyone way to solve this problem?
thanks so much!!!
If you know your output URL then you should try to pass the value by using setAttribute method or the custom-attribute component. See:
http://www.zkoss.org/doc/devguide-single/index.html#id459905
Hope this helps.
thanks
but my question is how I can obtain the_url_generated_of_report? y was research in source code of jasperreport component and am not found anyone method that returns me it
I think ZK jasperreport component doesn't provide an url for downloading or external usage.
please post it to feature request .
Hi,
this is a little bit old thread, but I have seen more people asking this, so one solution is here: http://zh.zkoss.org/forum/listComment/2677
But I think this solution is too much memory consuming - the whole PDF stored in session. Also, the user cannot "reload" the report. And the PDF will stay in the session, if something wrong happens and the client browser would not trigger the jasperreport servlet. At least the soft references should be used, to avoid out of memory error.
Other solution it to pass into the session just the Jasper Report, like # net.sf.jasperreports.j2ee.servlets.PdfServlet. But again, soft references should be used.
IMHO the best solution is the old good way of passing to the "jasperreport servlet" just a few parameters in URL query string, e.g. ?id1=XXX&id2=YYYY and then the servlet should create the report.
If you cannot pass parameters in URL, then put them into the session, usually they will take much less memory then the PDF. In this situation you can use soft/weak references in this way. Usage of weak references:
- store the parameters in the original desktop/page
- make a weak references and store them into the session, or use weak hash map
- open "jasperreport servlet" in a new window. the user can now reload "reload" the report as long as the weak references exists, that is as long as the original desktop/page exists
xmedeko@ not interessted?
JasperReport jasperReport = JasperCompileManager.compileReportToFile (java.lang.String sourceFileName, java.lang.String destFileName)
JasperPrint jasperPrint = JasperFillManager.fillReport (JasperReport jasperReport, java.util.Map parameters, JRDataSource dataSource)
JasperReport jasperReport = (JasperReport) JRLoader.loadObject (jasperFilePath)
JRDataSource dataSource = new JRResultSetDataSource(<b >Resultset</b>);
JRAbstractExporter
- PDF: JRPdfExporter - XML: JRXmlExporter - XLS: JRXlsExporter - CSV: JRCsvExporter - TXT: JRTextExporter
- TO FILE: JRAbstractExporter.OUTPUT_FILE_NAME filePathDestinationStr - TO STREAM: JRAbstractExporter.OUTPUT_STREAM outputStreamObject
httpResponse.setContentType("application/pdf"); httpResponse.setHeader("Content-disposition", "attachment; filename=MyFile.pdf"); ServletOutputStream out = httpResponse.getOutputStream(); //STEP 1: COMPILE REPORT (OPTIONAL ... U CAN USE DIRECTLY .jasper FILE AND SKIP THIS STEP) JasperReport jasperReport = .... .... .... //STEP 2: FILL REPORT JasperPrint jasperPrint = .... .... .... //STEP 3: EXPORT REPORT AND PUT INTO SERVLETOUTPUTSTREAM JRAbstractExporter exporter = JRPdfExporter(); Map<JRExporterParameter, Object> parameterExport = new HashMap<JRExporterParameter, Object>(); parameterExport.put((JRExporterParameter.JASPER_PRINT, jasperPrint); parameterExport.put((JRPdfExporterParameter.OUTPUT_STREAM,out); exporter.setParameters(parameterExport): exporter.exportReport(); out.flush();
@PeterKou FYI, I have opened this thread again, because it is linked from http://docs.zkoss.org/wiki/Jasper. (Although the link is old, I will update it).
Hi smigol,
th@nx for your post. This morning I start to integrate jasper in our project and your post helps me a lot !
Only two hints from me, which costs me a little time, and may help anyone.....
I use iReport 3.7.4 to design and compile the reportfile.
The following code:
JasperPrint jasperPrint = JasperFillManager.fillReport(session.getWebApp().getRealPath("/WEB-INF/jasper/report3.jasper"), new HashMap(),source);
Problem seems: compability issue
If there are compability problems with compiled files and jasper-lib the save way is to compile at runtime.
To compile at runtime I need Apache commons-beanutils-.jar and commons-digester.jar to add to WEB-INF/lib
@ZK-Team: Maybe an idea to add this to zkpe-bin-5.0.3\dist\lib\ext ???
Best regards,
Jörg
Asked: 2008-11-05 22:21:30 +0800
Seen: 6,948 times
Last updated: May 05 '12