I am using JasperReport and ireport in my JSF application to generate reports on the fly. This is what I am trying to achieve:-
My structure(read as HashMap
If you already have a DataSource then you can pass your List/Map thourgh the param Map when you're filling your report.
Map<String, Object> param = new HashMap<String, Object>();
param.put("SUB_DATA_SOURCE", yourList);
JasperFillManager.fillReport(jasperReport, param,
new JRBeanCollectionDataSource(yourMainListHere));
Doing that you have to create a parameter inside your MAIN report with the same name you have set in your param Map and also give to this a Type Class (List in my case).
Than you have to create your subreport element and set the Connection Type as "Use a datasource expression" and inside the "Data Source Expression" you set this:
new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{SUB_DATA_SOURCE})