Here is my java objects :
Class1.java :
public class Class1 {
public Class2 object2;
...
}
Class2.java :
public class Class2 {
public Class3 object3;
...
}
Class3.java :
public class Class3 {
public List<Class4> list4;
...
}
Class4.java :
public class Class4 {
public String string1;
public String string2;
public String string3;
public Class5 object5;
...
}
I have a report with a subreport and both use the same Datasource as you can see below :
public static void execute(List<Class1> data) throws FileNotFoundException, JRException {
BufferedInputStream reportStream = new BufferedInputStream(new FileInputStream("C:/Users/user1/Downloads/report2.jrxml"));
// Bing the datasource with the collection
JRDataSource datasource = new JRBeanCollectionDataSource(data, false);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("SUBREPORT_DIR", "C:\\Users\\user1\\Downloads\\");
parameters.put("SUB_DATA_SOURCE", data);
// Compile and print the jasper report
JasperReport report = JasperCompileManager.compileReport(reportStream);
JasperPrint print = JasperFillManager.fillReport(report, parameters, datasource);
// Export report to PDF
JasperExportManager.exportReportToPdfFile(print, "C:/Users/user1/Downloads/JavaBeansPDF.pdf");
}
SUB_DATA_SOURCE is a parameter that I defined into my report & my subreport in iReport with Parameter Class : java.util.List
I have tried to display simple values from Class1 into the report, and it works.
But my issue is how to display the content of my list List<Class4> list4
into the subreport.
I need to display this "table" in my report :
string1 ------- string2 ------- string3 ------- object5.getElement1 ...
abc ------------- cde ---------- test ------------- value1 ...
I don't know if my issue is clear, please tell if something is confusing or missing.
PS: I'm using JasperReports v5.6.0 and iReport v5.6.0