dhruvil.27392 Posted August 2, 2016 Posted August 2, 2016 I am using report book in Jasper reports and in that, I have to create a Content-report (same as sub-report) containing a table.I am using JRBeanCollectionDataSource. when I compile and run the sub-report individually, It works perfectly. but when I run whole Report book, then it won't even print that Subreport, other sub reports will be printed as expected. I am sure that, I am missing some minor settings. Because in report book, I am using chart, crosstab they are working fine. but the only problem is with that table. this is my subreport jrxml: ..insert your code here.. [/code] <?xml version="1.0" encoding="UTF-8"?> <!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.3.0 --> <!-- 2016-08-02T13:49:19 --> <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="sub_filter_table" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="5ec68712-81e7-4231-85ad-a535169f9480"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> <property name="net.sf.jasperreports.print.create.bookmarks" value="true"/> <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="filterTableDataset" uuid="5e16eed0-53ee-4e32-9078-a3f75f05ca4e"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> <parameter name="filterTableDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/> <queryString> <![CDATA[]]> </queryString> <field name="database" class="java.lang.String"/> <field name="systemNumber" class="java.lang.String"/> <field name="channels" class="java.lang.String"/> <field name="from" class="java.lang.String"/> <field name="to" class="java.lang.String"/> <field name="keep" class="java.lang.String"/> <field name="description" class="java.lang.String"/> </subDataset> <parameter name="filterTableDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/> <parameter name="filter_table_title" class="java.lang.String"> <defaultValueExpression><![CDATA["Filter logs"]]></defaultValueExpression> </parameter> <parameter name="SITE" class="java.lang.String"/> <queryString> <![CDATA[]]> </queryString> <background> <band splitType="Stretch"/> </background> <summary> <band height="342"> <componentElement> <reportElement x="0" y="110" width="555" height="100" uuid="f7bcc7fb-0f93-41a1-96fd-a17d82997667"> <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"/> <property name="com.jaspersoft.studio.components.autoresize.proportional" value="true"/> <property name="com.jaspersoft.studio.components.autoresize.next" value="true"/> </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="filterTableDataset" uuid="c89753d2-101b-4cbc-a23b-0c83bd725c45"> <parametersMapExpression><![CDATA[$P{filterTableDataSource}]]></parametersMapExpression> <datasetParameter name="filterTableDataSource"> <datasetParameterExpression><![CDATA[$P{filterTableDataSource}]]></datasetParameterExpression> </datasetParameter> <dataSourceExpression><![CDATA[$P{filterTableDataSource}]]></dataSourceExpression> </datasetRun> <jr:column width="73" uuid="1f2db4a6-020e-47f7-baf2-3544dcb71121"> <jr:columnHeader style="Table_CH" height="30"> <staticText> <reportElement x="0" y="0" width="73" height="30" uuid="14c78a1d-169f-4a55-9a9c-754fa02fd371"/> <text><![CDATA[database]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="73" height="30" uuid="4e86a802-0103-43ea-85fb-ae227412b60f"/> <textFieldExpression><![CDATA[$F{database}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="73" uuid="b21d7484-4645-4759-b3a1-e0dc7dc2cdf9"> <jr:columnHeader style="Table_CH" height="30"> <staticText> <reportElement x="0" y="0" width="73" height="30" uuid="a74174db-9266-4a63-8571-3e6b7a5e671a"/> <text><![CDATA[systemNumber]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="73" height="30" uuid="06a5dd33-40a5-48dd-93b2-ed21a86894b1"/> <textFieldExpression><![CDATA[$F{systemNumber}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="73" uuid="672670d2-071a-4987-b9b5-b9ccec62ffcd"> <jr:columnHeader style="Table_CH" height="30"> <staticText> <reportElement x="0" y="0" width="73" height="30" uuid="02b4645f-4e30-40f7-8229-bbb01dd3fc94"/> <text><![CDATA[channels]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="73" height="30" uuid="94eb42f5-b3f2-4592-b5f7-5a4cc48f1eec"/> <textFieldExpression><![CDATA[$F{channels}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="68" uuid="83e9f896-849b-4d96-bde7-c35f73824100"> <jr:columnHeader style="Table_CH" height="30"> <staticText> <reportElement x="0" y="0" width="68" height="30" uuid="30b2d1c9-4cd0-4358-9df9-aa7fa99c22a2"/> <text><![CDATA[from]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="68" height="30" uuid="64748c55-8224-4ba2-8275-13c13a2b66a5"/> <textFieldExpression><![CDATA[$F{from}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="54" uuid="896e3191-2c4a-428d-a65f-658375611c01"> <jr:columnHeader style="Table_CH" height="30"> <staticText> <reportElement x="0" y="0" width="54" height="30" uuid="34bfb207-d3e0-4343-8a7b-69aa6b15e881"/> <text><![CDATA[to]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="54" height="30" uuid="65268f63-f9c2-487f-9de6-b6045c3f8f33"/> <textFieldExpression><![CDATA[$F{to}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="59" uuid="ca8721df-5260-41c3-b549-19f7478831d2"> <jr:columnHeader style="Table_CH" height="30"> <staticText> <reportElement x="0" y="0" width="59" height="30" uuid="558d37f8-a6e0-49a0-948f-3a8352c014ca"/> <text><![CDATA[keep]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="59" height="30" uuid="5d15ec66-40c1-4b91-b330-639783230764"/> <textFieldExpression><![CDATA[$F{keep}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="155" uuid="94e61aed-be5f-4d95-9342-0a4a129e7fb8"> <jr:columnHeader style="Table_CH" height="30"> <staticText> <reportElement x="0" y="0" width="155" height="30" uuid="737886b1-2568-4840-8d59-b6bef0bb46ed"/> <text><![CDATA[description]]></text> </staticText> </jr:columnHeader> <jr:detailCell style="Table_TD" height="30"> <textField> <reportElement x="0" y="0" width="155" height="30" uuid="f451bec1-8ae6-4ee5-b4ca-fb337b5c94fb"/> <textFieldExpression><![CDATA[$F{description}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> </jr:table> </componentElement> <textField bookmarkLevel="2"> <reportElement x="140" y="20" width="170" height="30" uuid="af7d5b5d-e209-4417-9830-0994cd6d5b39"/> <textFieldExpression><![CDATA[$P{filter_table_title}]]></textFieldExpression> <anchorNameExpression><![CDATA[$P{filter_table_title}]]></anchorNameExpression> </textField> <textField> <reportElement x="436" y="46" width="100" height="30" uuid="924b35b3-34f5-47ad-b404-9483044489b2"/> <textFieldExpression><![CDATA[$P{SITE}]]></textFieldExpression> </textField> </band> </summary> </jasperReport>[/code] main Report-book jrxml ..insert your code here.. [/code] <?xml version="1.0" encoding="UTF-8"?> <!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.3.0 --> <!-- 2016-08-02T13:50:30 --> <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="Abstract_Book" pageWidth="595" pageHeight="842" sectionType="Part" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30" whenResourceMissingType="Error" uuid="d2716064-8ae4-40cf-a575-33afba400e3a"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> <property name="net.sf.jasperreports.print.create.bookmarks" value="true"/> <property name="com.jaspersoft.studio.book.group.cover.header" value="Cover and Table of Contents"/> <property name="com.jaspersoft.studio.book.group.cover.footer" value="Backcover"/> <parameter name="SUBREPORT_DIR" class="java.lang.String"/> <parameter name="Name" class="java.lang.String"> <parameterDescription><![CDATA[]]></parameterDescription> </parameter> <parameter name="XYChartDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/> <parameter name="tableDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/> <parameter name="IMAGE_DIR" class="java.lang.String"/> <parameter name="filterTableDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/> <parameter name="externalDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/> <parameter name="REPORT_TYPE" class="java.lang.String"/> <parameter name="SITE" class="java.lang.String"/> <parameter name="CMS" class="java.lang.String"/> <parameter name="OPPORTUNITY_ID" class="java.lang.String"/> <parameter name="windTableDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/> <queryString> <![CDATA[]]> </queryString> <group name="cover"> <groupHeader> <part uuid="7aed05b9-1301-4a53-b47e-34289560bc0c"> <p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd"> <subreportParameter name="Name"> <subreportParameterExpression><![CDATA[$P{Name}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="externalDataSource"> <subreportParameterExpression><![CDATA[$P{externalDataSource}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="REPORT_TYPE"> <subreportParameterExpression><![CDATA[$P{REPORT_TYPE}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="CMS"> <subreportParameterExpression><![CDATA[$P{CMS}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="SITE"> <subreportParameterExpression><![CDATA[$P{SITE}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="OPPORTUNITY_ID"> <subreportParameterExpression><![CDATA[$P{OPPORTUNITY_ID}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="IMAGE_DIR"> <subreportParameterExpression><![CDATA[$P{IMAGE_DIR}]]></subreportParameterExpression> </subreportParameter> <subreportExpression><![CDATA[$P{SUBREPORT_DIR}+"/Abstract_Book_cover.jasper"]]></subreportExpression> </p:subreportPart> </part> <part evaluationTime="Report" uuid="56ab525c-754f-4f48-a52c-7cc23934be3d"> <property name="net.sf.jasperreports.bookmarks.data.source.parameter" value="REPORT_DATA_SOURCE"/> <p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd"> <subreportExpression><![CDATA[$P{SUBREPORT_DIR}+"/Abstract_Book_toc.jasper"]]></subreportExpression> </p:subreportPart> </part> </groupHeader> <groupFooter> <part uuid="88decbbe-63ad-45cc-9e03-5dadc50004d5"> <p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd"> <subreportExpression><![CDATA[$P{SUBREPORT_DIR}+"/Abstract_Book_backcover.jasper"]]></subreportExpression> </p:subreportPart> </part> </groupFooter> </group> <detail> <part uuid="3d143dd6-5587-4c12-90f0-ff77f9d026af"> <p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd"> <subreportParameter name="SITE"> <subreportParameterExpression><![CDATA[$P{SITE}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="REPORT_DATA_SOURCE"> <subreportParameterExpression><![CDATA[$P{filterTableDataSource}]]></subreportParameterExpression> </subreportParameter> <subreportExpression><![CDATA[$P{SUBREPORT_DIR}+"/sub_filter_table.jasper"]]></subreportExpression> </p:subreportPart> </part> <part uuid="5e668430-9acd-4835-be21-f4e2902ce33d"> <p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd"> <subreportParameter name="REPORT_DATA_SOURCE"> <subreportParameterExpression><![CDATA[$P{XYChartDataSource}]]></subreportParameterExpression> </subreportParameter> <subreportExpression><![CDATA[$P{SUBREPORT_DIR}+"/sub_chart.jasper"]]></subreportExpression> </p:subreportPart> </part> <part uuid="0e5ec483-6a4d-4323-8cb8-850ca3cefe34"> <p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd"> <subreportParameter name="REPORT_DATA_SOURCE"> <subreportParameterExpression><![CDATA[$P{tableDataSource}]]></subreportParameterExpression> </subreportParameter> <subreportExpression><![CDATA[$P{SUBREPORT_DIR}+"/sub_crosstab.jasper"]]></subreportExpression> </p:subreportPart> </part> <part uuid="f4249881-1728-4f1f-8c54-75fc7725f6f6"> <p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd"> <subreportParameter name="REPORT_DATA_SOURCE"> <subreportParameterExpression><![CDATA[$P{windTableDataSource}]]></subreportParameterExpression> </subreportParameter> <subreportExpression><![CDATA[$P{SUBREPORT_DIR}+"/sub_wind_crosstab.jasper"]]></subreportExpression> </p:subreportPart> </part> </detail> </jasperReport>[/code]
kkriplani Posted August 2, 2016 Posted August 2, 2016 Hi,Look into the below listed two points;1) Check the logs if there is any error (if error occurs, share the error).2) From the logs, also rerun the query to check if the values are populated for the selected parameters.Regards,KKriplani
dhruvil.27392 Posted August 2, 2016 Author Posted August 2, 2016 Nope, there are no Errors in sub-report or main-report.As I have written, If I run this sub-report individually. it will work fine. but only thing is when I run the main-report then it doesn't shows up any content from the table. other sub reports are working fine. do you have any example where table is being generated in sub reports and JRBeanCollectionDatasource is used ?
kkriplani Posted August 3, 2016 Posted August 3, 2016 I am afraid I dont have any such examples, but tell me a couple of things;1) When you execute the complete report with table as subreport, the query in the logs for the table is returning data in the database?2) Have you linked the parameters of main report and sub report?If the answer to point 2 is no, probably null values are passing for parameters in the table query when you execute the report as a whole consisting of the table as a subreport.Hope this helps,KKriplani
dhruvil.27392 Posted August 3, 2016 Author Posted August 3, 2016 Firstly, I don't have database, I am using JRBeanCollectionDatasource.In my table-Subreport, I do have Two extra parameter, which I map from main report to sub report. And they are working fine.they will be printed perfectly.But nothing of table is being printed.(Not even headers). If possible, can you make two jrxml files for the code which I have attached, then you will get better Idea.I was unable to find any link/resource regarding this topic 'table inside subreports using JRBeanCollectionDatasource '.it will be a great help, if you can help me with this.
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