p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   J2EE (http://p2p.wrox.com/forumdisplay.php?f=94)
-   -   Send ArrayList from jsf to jasperreport as Datasource (http://p2p.wrox.com/showthread.php?t=86312)

jaykio77 January 12th, 2012 06:59 AM

Send ArrayList from jsf to jasperreport as Datasource
Hello Forum.
i have an array list in jsf bean that i want user to print via jasperreport.
i followed following steps.
1. use empty datasource in jasper report.
2. created Fields in jasper reports as those of my bean properties.
i tried both (Employee.name) and only name.
3. then i compiled the report to employeeList.jasper and placed that in my
/reports/EmployeeReports/employeeList.jasper folder in jsf project.
4. I have then used following code to fill and show the pdf report to user

JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(this.srchdEmployeesList);
                FacesContext facesContext = FacesContext.getCurrentInstance();
                HttpServletResponse response = (HttpServletResponse)facesContext.getExternalContext().getResponse();
                HashMap parameterMap = new HashMap();
                JasperPrint jasperPrint = JasperFillManager.fillReport("/reports/EmployeeReports/employeeList.jasper", parameterMap, dataSource);
                InputStream reportStream = facesContext.getExternalContext().getResourceAsStream("/reports/EmployeeReports/employeeList.jasper");
                ServletOutputStream servletOutputStream = response.getOutputStream();
                Session hibernateSession = null;
                hibernateSession = HibernateUtils.currentSession();
                connection = hibernateSession.connection();
                response.setHeader("Content-disposition", "attachment;");
JasperRunManager.runReportToPdfStream(reportStream,servletOutputStream, parameterMap, connection);

but the problem is, my report is not filling. Plz let me know where am i wrong. i will be obliged.

All times are GMT -4. The time now is 01:42 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.