I am using a bean object for a datasource. The data source contain several properties-- one of which is a list of line items that I am trying to to use.. By bean looks like like this:
String name;
String address;
List<DetailRecord> records;
I want to have the records show up as the detail lines int the report. I know I need to setup a sub-report, but I'm not sure how to set the sub-report to use the records element of the current parent data item as the datasource.
Ok..I figured out what I needed to do. For the sub-report I need to specify the datasource this way:
new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{records})
There are a couple of "Gotcha's" here that had me stuck for a little while:
My attempts kept bombing (with no visible error) due to the fact that the records field in the parent was defaulted to String. Once I changed it to a list, things started working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With