Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
Password Reminder
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #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
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.

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 09:36 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.