Java objects as datasources

In addition to databases and maps, JasperReports allows us to use Plain Old Java Objects (POJOs) as datasources. We can use any Java object that adheres to the JavaBeans specification as a datasource. The only requirement for an object to adhere to the JavaBeans specification is that it must have no public properties, it must have a no-argument constructor, and it must provide getter and setter methods to access its private and protected properties. Let's create a Java object to be used as a datasource for our next example:

package net.ensode.jasperbook; public class AircraftData { public AircraftData(String tail, String serial, String model,String engine) { setTailNum(tail); setAircraftSerial(serial); setAircraftModel(model); ...

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.