michael.samir.g Posted May 24, 2019 Share Posted May 24, 2019 I have a jasper report that has main report and detail report as a list, the data is being sent from server side Java as a java bean that has some attributes including a list of another Java bean, this list is used to fill the detail list, the problem is that, the client need that each detail record should be in a separate pageI already try to use Break at end of the list layout, but when I try to generate the report I got the error:Caused by: java.lang.NullPointerException at net.sf.jasperreports.engine.fill.JRFillBreak.prepare(JRFillBreak.java:218) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:537) at net.sf.jasperreports.components.list.FillListContents.prepare(FillListContents.java:92) at net.sf.jasperreports.components.list.VerticalFillList.fillContents(VerticalFillList.java:164) at net.sf.jasperreports.components.list.VerticalFillList.prepare(VerticalFillList.java:111) at net.sf.jasperreports.engine.fill.JRFillComponentElement.prepare(JRFillComponentElement.java:152) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:537) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:411) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:386) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2024) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:748) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:255) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:582) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:414) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:121) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:667) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:983)[/code]Here's the java code for generating the report:due to sensitive client information I couldn't provide the exact code but the same structureReport Beanpublic class ReportBean implements Serializable { // Main attributes used in the Main report Header and Footer private String attr1; private String attr2; private List<DetailBean> list; // setters and getters}[/code]Detail Beanpublic class DetailBean implements Serializable { // Detail attributes used in the list details to show detail records private String attr1; private String attr2; // setters and getters}[/code]Generating Report// createReport() function retrieve data from data base, fill the main report information and the detail report listReportBean report = createReport();String filename = "";byte[] result = null;try (InputStream is = new FileInputStream(filename)) { result = JasperReportsGenerator.createPDF(is, Collections.singletonList(report), params);}catch (IOException e) {}[/code] And here's the report structure:Main ReportList detailsReport structureThanks in advance Link to comment Share on other sites More sharing options...
C-Box Posted May 26, 2019 Share Posted May 26, 2019 Don't use list element...my experience says, that un most cases you will come to rhe limitations of list element and you will refactor it to subreport. So just change to subreport and place the break element into the detail section of the subreport, so that each record will do an break.You could then also use groups and also the group feature StartOnNewPageHth + regardsC-Box Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now