I am trying to create a report with 2 sub-reports for new and used vehicles.
I have defined a vehicle bean as per the JavaBeans specification. I was thinking of using a parameter map to pass this data to the sub report via the main report as was described at Passing JRBeancollection datasourse to master report and subreport post.
Steps I took so far are as follows:
The first step - Passing collection as parameter
Map<String, Object> jasperParameter = new HashMap<String, Object>();
jasperParameter.put("new_Vehicles", createNewVehicles()); //returns a collection of vehicles.
The second step - Creating a parameter, new_Vehicles
in my main report and set it as Collection
data type
The third step - Creating a data source expression for the sub-report as
net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{new_Vehicles})
The fourth step - Creating a field (just to get this working before I add more fields), vehicleId
in the sub report.
Question/Issues I am having and would appreciate any help is:
a) When I compile it gives me an error message that the above mentioned data source cannot be resolved to a type. What am I doing incorrectly?
Ok, so I think I might have gone past the exception by adding "new" in front of the data expression, new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{new_Vehicles})
.
But, now if there are two new vehicles that I add to the list its printing in two pages, basically one page per element in the list. My column headers are in the Column Header band and my fields are in the Detail band.
Any suggestions on how I can prevent it from putting each element in the list on a different page?
Delete your unused bands and/or adjust the detail band to the same height as your fields.
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