Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
JasperReports 3.5 for Java Developers

You're reading from  JasperReports 3.5 for Java Developers

Product type Book
Published in Aug 2009
Publisher Packt
ISBN-13 9781847198082
Pages 368 pages
Edition 1st Edition
Languages

Table of Contents (17) Chapters

JasperReports 3.5 for Java Developers
Credits
About the Author
About the Reviewers
Preface
An Overview of JasperReports Adding Reporting Capabilities to our Java Applications Creating your First Report Creating Dynamic Reports from Databases Working with Other Datasources Report Layout and Design Adding Charts and Graphics to Reports Other JasperReports Features Exporting to Other Formats Graphical Report Design with iReport Integrating JasperReportswith Other Frameworks Index

Map datasources


JasperReports allows us to use instances of any class implementing the java.util.Map interface as a datasource. We can use either an array or a collection of Map objects to generate a report. Each Map in the collection or array is a record that will be used to generate the data for each row in the detail area of the report. The JasperReports API provides an implementation of net.sf.jasperreports.engine.JRDataSource called net.sf.jasperreports.engine.data.JRMapArrayDataSource that we can use for using an array of Map objects as a datasource. The following example demonstrates this class in action:

package net.ensode.jasperbook;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}