However, I don't know how to do that. Because of the list of answer is inside the list of question. The structure just like the following code:
// Paper
public class Paper{
public
String name;
public List<Question> questions;
}
// Question
public class Question{
public String question;
public List<Answer> answers;
}
// Answer
public class Answer{
public String answer;
}
// Generate the pdf of Paper + Question subReport
InputStream mainInStream = getClass().getResourceAsStream("../paper.jasper");
InputStream questionInStream = getClass().getResourceAsStream("../question.jasper");
JasperReport jRpt = (JasperReport) JRLoader.loadObject(mainInStream);
JasperReport question= (JasperReport)JRLoader.loadObject(questionInStream);
JRBeanCollectionDataSource questionDS = new JRBeanCollectionDataSource(this.paperBean.paperQuestions);
Map<String, Object> main = new HashMap();
main.put("name", this.paper.name);
main.put("subReport", question);
main.put("questionDatasource", questionDS);
JasperPrint jPrint = JasperFillManager.fillReport(jRpt, main, new JREmptyDataSource());
JasperExportManager.exportReportToPdfFile(jPrint, "D:/test.pdf");
So I don't know how to put the list of answer to be the datasource inside the datasource of questionDS.