Thursday, January 3, 2013

Passing JavaBean Datasource to JasperReports

As the title suggests the tutorial is about passing javabean as a datasource to jasper reports instead of a db connection. To make it work, create a POJO class as below with two variables.

 Than create a generic arraylist of Person and pass it into JasperFillManager as a datasource using JRBeanCollectionDataSource object. Sample code as below.


In the jasper file, just create two String fields as below which has the exact name of the variables in the POJO class.

Run the main file and the output will be as below:


Author: Thiagu