Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JasperReports: Passing lists via parameter map & detail records getting printed on a new page per record

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?

like image 902
user1486984 Avatar asked Oct 22 '22 14:10

user1486984


1 Answers

Delete your unused bands and/or adjust the detail band to the same height as your fields.

like image 118
Diego Urenia Avatar answered Nov 02 '22 06:11

Diego Urenia