raulhsj Posted December 9, 2020 Share Posted December 9, 2020 Hi all,Due to being a newbie, I am havaing a bad time trying to get to work a report with a list (subreport) and a table nested in it (subreport), externally sourcing from a java HashMap with a list of java beans (each one containing another list), and the paths to the subreports along. All reports compile, but when I ask for the main in .pdf, it is generated but can't be opened.Please find them attached, hierarchically ordered:main.jrxml<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.16.0.final using JasperReports Library version 6.16.0-48579d909b7943b64690c65c71e07e0b80981928 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="89314bb5-8879-4d1e-9c93-ba44338696d3"> <import value="es.toqio.tsb.wallet.enums.*"/> <parameter name="startDate" class="java.lang.String"/> <parameter name="endDate" class="java.lang.String"/> <parameter name="companyName" class="java.lang.String"/> <parameter name="companyAddress1" class="java.lang.String"/> <parameter name="companyAddress2" class="java.lang.String"/> <parameter name="companyCity" class="java.lang.String"/> <parameter name="companyPostalCode" class="java.lang.String"/> <parameter name="companyCountry" class="java.lang.String"/> <parameter name="subReportAccounts" class="java.lang.String"/> <parameter name="accounts" class="java.util.List"/> <parameter name="subReportTransactions" class="java.lang.String"/> <queryString> <![CDATA[]]> </queryString> <background> <band splitType="Stretch"/> </background> <title> <band height="191" splitType="Stretch"> <staticText> <reportElement x="0" y="0" width="120" height="20" uuid="0a2acbff-ca52-427a-bbce-ae98aeb2e95a"/> <textElement> <font isBold="true"/> </textElement> <text><![CDATA[Transaction Statement]]></text> </staticText> <textField> <reportElement x="30" y="20" width="70" height="20" uuid="4fcaf10c-e35d-4628-8d48-8a48c653b942"/> <textFieldExpression><![CDATA[$P{startDate}]]></textFieldExpression> </textField> <textField> <reportElement x="120" y="20" width="60" height="20" uuid="a851b48a-183f-4de3-abf9-aae0778a41f6"/> <textFieldExpression><![CDATA[$P{endDate}]]></textFieldExpression> </textField> <textField> <reportElement x="100" y="20" width="20" height="20" uuid="7bf7d2c9-ee1f-40ae-9782-df1e7e6f88f4"/> <textFieldExpression><![CDATA["to"]]></textFieldExpression> </textField> <textField> <reportElement x="0" y="21" width="30" height="19" uuid="240a0ac5-d3c9-4db5-9509-58d1794dcc22"/> <textFieldExpression><![CDATA["from"]]></textFieldExpression> </textField> <textField> <reportElement x="2" y="71" width="150" height="20" uuid="c5aea5ed-7db8-449b-bb75-3796d642d787"/> <textElement> <font isBold="true"/> </textElement> <textFieldExpression><![CDATA[$P{companyName}]]></textFieldExpression> </textField> <textField> <reportElement x="2" y="91" width="150" height="20" uuid="bf472ba5-8aa3-4845-9e43-5bad4e4c450e"/> <textFieldExpression><![CDATA[$P{companyAddress1}]]></textFieldExpression> </textField> <textField> <reportElement x="2" y="111" width="150" height="20" uuid="639f9308-e832-4132-bf99-ff9e50af2a2f"/> <textFieldExpression><![CDATA[$P{companyAddress2}]]></textFieldExpression> </textField> <textField> <reportElement x="2" y="131" width="150" height="20" uuid="754a2569-88c8-44cd-bbc7-650df4e16315"/> <textFieldExpression><![CDATA[$P{companyCity}]]></textFieldExpression> </textField> <textField> <reportElement x="2" y="151" width="150" height="20" uuid="31bfd08d-a842-4e3c-8f64-6b8eb7dfe95f"/> <textFieldExpression><![CDATA[$P{companyPostalCode}]]></textFieldExpression> </textField> <textField> <reportElement x="2" y="171" width="150" height="20" uuid="a30a713c-90e4-45e2-9432-26299d041f3c"/> <textFieldExpression><![CDATA[$P{companyCountry}]]></textFieldExpression> </textField> </band> </title> <detail> <band height="208" splitType="Stretch"> <subreport> <reportElement x="2" y="8" width="548" height="192" uuid="e562b9f2-5285-474a-9122-4632cd12142f"/> <parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression> <subreportExpression><![CDATA[$P{REPORT_CONTEXT}.getParameterValue("subReportAccounts")]]></subreportExpression> </subreport> </band> </detail></jasperReport>subReportAccounts.jrxml<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.16.0.final using JasperReports Library version 6.16.0-48579d909b7943b64690c65c71e07e0b80981928 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="accounts" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f73bb3ab-443d-40ef-a1e8-d66743196671"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> <subDataset name="accountsListDataSet" uuid="1cafbb8f-2084-49bd-812a-5cefdb7452ad"> <queryString> <![CDATA[]]> </queryString> <field name="type" class="java.lang.String"> <fieldDescription><![CDATA[type]]></fieldDescription> </field> <field name="iban" class="java.lang.String"> <fieldDescription><![CDATA[iban]]></fieldDescription> </field> <field name="bicSwift" class="java.lang.String"> <fieldDescription><![CDATA[bicSwift]]></fieldDescription> </field> <field name="ukAccountNumber" class="java.lang.String"> <fieldDescription><![CDATA[ukAccountNumber]]></fieldDescription> </field> <field name="ukSortCode" class="java.lang.String"> <fieldDescription><![CDATA[ukSortCode]]></fieldDescription> </field> <field name="transactions" class="java.util.List"> <fieldDescription><![CDATA[transactions]]></fieldDescription> </field> </subDataset> <queryString> <![CDATA[]]> </queryString> <background> <band splitType="Stretch"/> </background> <pageHeader> <band height="190" splitType="Stretch"> <componentElement> <reportElement x="0" y="0" width="550" height="170" uuid="6526f851-73b6-4dd2-b716-374ce8a229ac"/> <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical"> <datasetRun subDataset="accountsListDataSet" uuid="07135cb5-b2f5-4d06-924c-cbe70540864e"> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource((java.util.List)$P{REPORT_PARAMETERS_MAP}.get("accounts"))]]></dataSourceExpression> </datasetRun> <jr:listContents height="170" width="550"> <textField> <reportElement x="0" y="0" width="20" height="20" uuid="c60cdba2-2890-4242-a43e-49e39ba47861"/> <textFieldExpression><![CDATA[$F{type}]]></textFieldExpression> </textField> <textField> <reportElement x="100" y="18" width="140" height="20" uuid="5ef8707e-1b44-4826-a631-73596cbbd11a"> <printWhenExpression><![CDATA[$F{iban} != null && ($F{ukAccountNumber} == null)]]></printWhenExpression> </reportElement> <textFieldExpression><![CDATA[$F{iban}]]></textFieldExpression> </textField> <textField> <reportElement x="100" y="40" width="100" height="20" uuid="8856ec50-a7f9-4209-9efa-5b3499dfa739"> <printWhenExpression><![CDATA[$F{bicSwift} != null && ($F{ukSortCode} == null)]]></printWhenExpression> </reportElement> <textFieldExpression><![CDATA[$F{bicSwift}]]></textFieldExpression> </textField> <textField> <reportElement x="101" y="18" width="140" height="20" uuid="497f6029-c18c-4689-a6ee-3f7e334bc901"> <printWhenExpression><![CDATA[$F{ukAccountNumber} != null && ($F{iban} == null)]]></printWhenExpression> </reportElement> <textFieldExpression><![CDATA[$F{ukAccountNumber}]]></textFieldExpression> </textField> <textField> <reportElement x="100" y="39" width="100" height="20" uuid="a496329e-98bd-4ef5-8c0b-9913c241f5e8"> <printWhenExpression><![CDATA[$F{ukSortCode} != null && ($F{bicSwift} == null)]]></printWhenExpression> </reportElement> <textFieldExpression><![CDATA[$F{ukSortCode}]]></textFieldExpression> </textField> <staticText> <reportElement x="20" y="0" width="100" height="20" uuid="b1df4789-da6f-4d78-8697-a5365c817463"/> <textElement> <font isBold="true"/> </textElement> <text><![CDATA[statement]]></text> </staticText> <textField> <reportElement x="0" y="20" width="102" height="21" uuid="cfb1320c-24fd-4c73-b5ff-fbe2ab9a26a7"/> <textElement> <font isBold="true"/> </textElement> <textFieldExpression><![CDATA[$F{iban} != null ? "IBAN (SEPA)" : "UK Account"]]></textFieldExpression> </textField> <textField> <reportElement x="0" y="38" width="100" height="21" uuid="925e5f96-580b-4bed-a74d-c446d60e1881"/> <textElement> <font isBold="true"/> </textElement> <textFieldExpression><![CDATA[$F{iban} != null ? "BIC (SEPA)" : "UK sort code"]]></textFieldExpression> </textField> <subreport> <reportElement x="0" y="70" width="550" height="90" uuid="9bb7ec8a-335d-479e-bd79-c1f51f6df70a"/> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{transactions})]]></dataSourceExpression> <subreportExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}.get("subReportTransactions")]]></subreportExpression> </subreport> </jr:listContents> </jr:list> </componentElement> </band> </pageHeader> <detail> <band height="227" splitType="Stretch"/> </detail></jasperReport>subReportTransactions.jrxml<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.16.0.final using JasperReports Library version 6.16.0-48579d909b7943b64690c65c71e07e0b80981928 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="transactionsInAccount" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="afbbff64-9533-4c58-9ef6-99f3788f7f61"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF"> <box> <pen lineWidth="0.5" lineColor="#000000"/> <topPen lineWidth="0.5" lineColor="#000000"/> <leftPen lineWidth="0.5" lineColor="#000000"/> <bottomPen lineWidth="0.5" lineColor="#000000"/> <rightPen lineWidth="0.5" lineColor="#000000"/> </box> </style> <subDataset name="transactionsInAccount" uuid="c5aabcb7-3724-4325-abd0-7d1942639f4c"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> <queryString> <![CDATA[]]> </queryString> <field name="date" class="java.util.Date"/> <field name="description" class="java.lang.String"/> <field name="balance" class="java.lang.String"/> <field name="baseTotal" class="java.lang.String"/> <field name="group" class="java.lang.String"/> </subDataset> <parameter name="transactions" class="java.util.List"/> <queryString> <![CDATA[]]> </queryString> <background> <band splitType="Stretch"/> </background> <detail> <band height="82" splitType="Stretch"> <componentElement> <reportElement x="0" y="0" width="550" height="50" uuid="2095995a-8ac7-4818-afd5-073e13e82c57"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/> <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/> <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/> </reportElement> <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"> <datasetRun subDataset="transactionsInAccount" uuid="747c9627-58b8-430d-a97a-b3c285a4a3ea"> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{transactions})]]></dataSourceExpression> </datasetRun> <jr:column width="90" uuid="dae88717-a63b-49e1-9d8b-6dd3489d59c5"> <jr:columnHeader style="Table_CH" height="20"> <textField> <reportElement x="0" y="0" width="90" height="20" uuid="aa16bfc5-6860-487c-992c-cecd8f180fca"/> <textFieldExpression><![CDATA["Completed Date"]]></textFieldExpression> </textField> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="90" height="30" uuid="6e821f3d-5268-443d-8c43-fde93bfcebef"/> <textFieldExpression><![CDATA[$F{date}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="280" uuid="e912fadb-2c79-451c-9467-9bd7248dbb11"> <jr:columnHeader style="Table_CH" height="20"> <textField> <reportElement x="0" y="0" width="280" height="20" uuid="961ca07a-5ece-4260-864d-dc945380ecc0"/> <textFieldExpression><![CDATA["Reference"]]></textFieldExpression> </textField> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="280" height="30" uuid="5854a6eb-565f-41c2-82c6-55a622450161"/> <textFieldExpression><![CDATA[$F{description}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="60" uuid="4c92bf38-781f-4de2-a8ac-a7bec753a19b"> <jr:columnHeader style="Table_CH" height="20"> <textField> <reportElement x="0" y="0" width="60" height="20" uuid="b49a8e31-3023-4366-9d71-f1ddb49dfb69"/> <textFieldExpression><![CDATA["Paid out"]]></textFieldExpression> </textField> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="60" height="30" uuid="55b5ffa3-de77-4e57-b475-b8ed74886607"> <printWhenExpression><![CDATA[$F{group}.equals("OUTBOUND")]]></printWhenExpression> </reportElement> <textFieldExpression><![CDATA[$F{baseTotal}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="60" uuid="b8a7f1c5-8424-4194-866f-62effb5dea4b"> <jr:columnHeader style="Table_CH" height="20"> <textField> <reportElement x="0" y="0" width="60" height="20" uuid="52750077-82e3-4263-98e4-c1a8a6568a60"/> <textFieldExpression><![CDATA["Paid in"]]></textFieldExpression> </textField> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="60" height="30" uuid="55b5ffa3-de77-4e57-b475-b8ed74886607"> <printWhenExpression><![CDATA[$F{group}.equals("INBOUND")]]></printWhenExpression> </reportElement> <textFieldExpression><![CDATA[$F{baseTotal}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="60" uuid="b8a7f1c5-8424-4194-866f-62effb5dea4b"> <jr:columnHeader style="Table_CH" height="20"> <textField> <reportElement x="0" y="0" width="60" height="20" uuid="cfe36e25-9646-42d2-a83b-cf2fb96eb1ad"/> <textFieldExpression><![CDATA["Balance"]]></textFieldExpression> </textField> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="60" height="30" uuid="ebce4aa0-e31f-4fa1-b4e9-4e067cb9772d"/> <textFieldExpression><![CDATA[$F{balance}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> </jr:table> </componentElement> </band> </detail></jasperReport>Best regards Link to comment Share on other sites More sharing options...
gustavofarias Posted December 9, 2020 Share Posted December 9, 2020 is it opened in other format other than PDF? Can you see your data in the main report? Link to comment Share on other sites More sharing options...
raulhsj Posted December 9, 2020 Author Share Posted December 9, 2020 Nope, I can't see any element in the list nor the nested table either Link to comment Share on other sites More sharing options...
gustavofarias Posted December 9, 2020 Share Posted December 9, 2020 forget the subreports, just try to print the data in your main report in detai band. Can you see any data? Link to comment Share on other sites More sharing options...
raulhsj Posted December 9, 2020 Author Share Posted December 9, 2020 I tried your approach but didn't know how to connect an element from the list to be a datasource for the table, I couldn't compile the report Link to comment Share on other sites More sharing options...
gustavofarias Posted December 9, 2020 Share Posted December 9, 2020 what do you mean with "sourcing from a java HashMap with a list of java beans"?Can't you write a simple report that has no subreports and just print your data? Link to comment Share on other sites More sharing options...
raulhsj Posted December 9, 2020 Author Share Posted December 9, 2020 A external java HashMap passed as datasource to the report, one element is a java.util.List (to show as a list) which contains pojos, and each of them contains another java.util.List (to show as a table) Link to comment Share on other sites More sharing options...
gustavofarias Posted December 9, 2020 Share Posted December 9, 2020 I don't know how do you pass a HashMap as datasource. Maybe you can explain better, but the question is, are you able to see your data? without this there is no point in worring about subreports. Link to comment Share on other sites More sharing options...
raulhsj Posted January 11, 2021 Author Share Posted January 11, 2021 I managed to compile and open the pdf at last. I can see some info from the HashMap but not the list and tables that comprise the brunt of the data 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