Java Reference
In-Depth Information
Working with Other
Datasources
In the previous chapter, we mentioned that JasperReports allows us to use not
only databases, but also many other sources of data to generate reports. In this
chapter, we will cover how to use datasources, other than databases, to create
our reports.Since creating web-based reports is by far the most common use
of JasperReports, most examples in this chapter will use the technique,
described in Chapter 3, to stream a PDF report to a web browser via the
JasperFillManager.fillReportToStream() method.
By the end of the chapter, you will be able to:
Use empty datasources for reports that don't require an external datasource
Use any implementation of java.util.Map as a datasource
Use arrays or collections of Java objects as datasources
Use TableModels as a datasource
Use an XML as a datasource
Create your own custom datasources
All JasperReports datasources implement the net.sf.jasperreports.engine.
JRDataSource interface. Reports are generated, or illed , by calling one of several
static methods in the net.sf.jasperreports.JasperFillManager class. The
JasperFillManager class contains several overloaded versions of the following
three methods:
JasperFillManager.fillReport() : The JasperFillManager.
fillReport() method creates a report and stores it in a net.
sf.jasperreports.engine.JasperPrint() object.
Search WWH ::




Custom Search