Custom datasources
So far we've seen all of the JRDataSource
implementations provided by JasperReports. If we need to extract data from a type of datasource not directly supported by JasperReports, we can create a class implementing JRDataSource
to meet our needs. In this section, we will create a custom datasource allowing us to generate reports from an instance of java.util.List
containing arrays of strings as its elements.
Writing a custom JRDataSource implementation
In our previous examples, all JasperReports datasources implement the JRDataSource
interface. JasperReports also includes the net.sf.jasperreports.engine.JRRewindableDataSource
interface. This interface extends JRDatasource
, adding a single method called moveFirst()
. The moveFirst() ...
Get JasperReports 3.5 for Java Developers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.