O'Reilly logo

JasperReports 3.5 for Java Developers by David Heffelfinger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required