Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
| Search | Today's Posts | Mark Forums Read
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 12th, 2012, 06:59 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs down 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
Code:
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();
		Class.forName("oracle.jdbc.driver.OracleDriver");
		Session hibernateSession = null;
		hibernateSession = HibernateUtils.currentSession();
		connection = hibernateSession.connection();
		facesContext.responseComplete();
		response.setContentType("application/pdf");
		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.

Last edited by jaykio77; January 14th, 2012 at 02:47 AM.. Reason: place tags for the code


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem getting selected value from DropDownList using ArrayList as DataSource kwilliams ASP.NET 3.5 Basics 1 December 2nd, 2011 03:40 PM
Building Web 2.0 UIs with JSF, Realtime Updates with JSF & Ajax Push Taught at GIDS Shaguf J2EE 0 March 4th, 2010 07:54 AM
Building Web 2.0 UIs with JSF, Realtime Updates with JSF & Ajax Push Taught at GIDS Shaguf J2EE 0 March 4th, 2010 07:53 AM
Arraylist is datasource for listbox. Failing. CharissaJB C# 2005 0 September 14th, 2006 10:33 AM
Error generating the jasperReport krishnatlk J2EE 0 April 27th, 2005 05:44 AM





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