jasper report is not showing table when using java bean datasource - jasper-reports

I am using JasperReports in my project using table component in the summary band and
providing data with JRBeanCollectionDataSource but after extracting the report getting only title of the report and table is not displaying.
Here is my .jrxml
<?xml version="1.0" encoding="UTF-8"?>
<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="CampaignSummary" language="groovy" pageWidth="1400" pageHeight="1000" orientation="Landscape" columnWidth="1360" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ef078799-c539-490f-b244-d493f4522ef2">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="163"/>
<property name="ireport.y" value="0"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#00FFFF"/>
<style name="table_CH" mode="Opaque" backcolor="#BFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
<style backcolor="#EFFFFF"/>
</conditionalStyle>
</style>
<subDataset name="TableDataset" uuid="c99fd89d-9d8f-488f-95db-360a7f5aba96">
<field name="CampaignID" class="java.lang.String">
<fieldDescription><![CDATA[me.CampaignID]]></fieldDescription>
</field>
<field name="CampaignName" class="java.lang.String">
<fieldDescription><![CDATA[Campaign Name]]></fieldDescription>
</field>
.
.
.
......some more fields....
.
.
<field name="NetImpact" class="java.lang.String">
<fieldDescription><![CDATA[Net Impact]]></fieldDescription>
</field>
</subDataset>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="54" splitType="Stretch">
<staticText>
<reportElement uuid="8b41287b-3930-416a-ba00-7f4a9c907e26" x="0" y="0" width="1360" height="54"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial Rounded MT Bold" size="24"/>
</textElement>
<text><![CDATA[Campaign Summary Report]]></text>
</staticText>
</band>
</title>
<summary>
<band height="239" splitType="Stretch">
<frame>
<reportElement uuid="61313d06-6df1-4212-ab8f-8e311dc5ad33" x="0" y="0" width="1360" height="87"/>
</frame>
<frame>
<reportElement uuid="c04b08f6-89d3-4104-87ba-adecd3c4f7dd" x="0" y="87" width="1360" height="152"/>
<componentElement>
<reportElement uuid="8afc21c1-7b57-4dab-8178-8810c1183dd9" key="table" style="table" x="0" y="0" width="1360" height="152"/>
<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="TableDataset">
<dataSourceExpression>
<![CDATA[($P{REPORT_DATA_SOURCE})]]>
</dataSourceExpression>
</datasetRun>
<jr:column width="90" uuid="eece2ecf-027d-4ef1-bd05-8d7d6bbbc0b0">
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement uuid="c0d108a0-9f4b-4ec3-b9d0-664ea0724584" x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[Campaign Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement uuid="6a8f7bf6-5e9b-4f77-a524-9a8d7f0ee2ca" x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[String.valueOf($F{CampaignName})]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
.
.
.some more columns...
.
<jr:column width="80" uuid="312f9143-cee8-46fb-a296-27172c4fca98">
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement uuid="22ec2935-d4a9-4b64-856d-e64d72f0d856" x="0" y="0" width="80" height="30"/>
<textElement/>
<text><![CDATA[Net Impact]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement uuid="071cddad-63f1-47bc-8da5-a2d6752e3abe" x="0" y="0" width="80" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[String.valueOf($F{NetImpact})]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</frame>
</band>
</summary>
and java code is
CampaignSummaryBeanFactory campaignSummaryBeanFactory =new CampaignSummaryBeanFactory();
JasperFillManager.fillReportToFile("build/reports/CampaignSummary.jasper", null, new JRBeanCollectionDataSource(campaignSummaryBeanFactory.getCampaignSummaryBeans()));

Table will not be displayed if it is empty.
Do you have any element in campaignSummaryBeanFactory.getCampaignSummaryBeans()?
For the case when you have no data, put something in the "No Data" band, some static text like 'No data to display' or even the header of your table, if you want to see the empty table when you have no rows.
As far as you code goes, the table will also be empty if you have 1 element in the datasource. Otherwise it will skeep the first record in the list. See Jasper report missing first row

You will find some people who tells you to put table in summary band. But that is the reason your table is not displaying. Put it in a detail band.

Related

How to introduce the page break after pre-defined number of rows in the jr:table component?

I am using jasper report version 6.1 and wanted page break after pre-defined number of rows in the jr:table component. I have also tried doing the same in version 5 and it works fine but in version 6+ I am not able to do it.
Sharing the links which I followed if any one have other solution please let me know.
http://community.jaspersoft.com/wiki/ireport-how-introduce-page-break-after-pre-defined-number-rows-table-component
http://community.jaspersoft.com/questions/845487/inserting-break-table-print-only-10-rows-page-jasper-reports-372
This is what I have tried:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.1.0.final using JasperReports Library version 6.1.0 -->
<!-- 2017-05-29T15:29:33 -->
<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_4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="957c1fea-8994-4195-9d7a-2bbf0baf7180">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Max apex"/>
<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="Dataset1" uuid="435d51b0-6d3e-442e-9a96-ae7412b12278">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Max apex"/>
<queryString>
<![CDATA[select * from dept]]>
</queryString>
<field name="DEPTNO" class="java.math.BigDecimal"/>
<field name="DNAME" class="java.lang.String"/>
<field name="LOC" class="java.lang.String"/>
<group name="DEPTNO">
<groupExpression><![CDATA[$F{DEPTNO}]]></groupExpression>
</group>
<group name="DNAME">
<groupExpression><![CDATA[$F{DNAME}]]></groupExpression>
</group>
<group name="LOC">
<groupExpression><![CDATA[$F{LOC}]]></groupExpression>
</group>
</subDataset>
<queryString>
<![CDATA[select * from dept]]>
</queryString>
<field name="DEPTNO" class="java.math.BigDecimal"/>
<field name="DNAME" class="java.lang.String"/>
<field name="LOC" class="java.lang.String"/>
<group name="DEPTNO">
<groupExpression><![CDATA[$F{DEPTNO}]]></groupExpression>
</group>
<group name="DNAME">
<groupExpression><![CDATA[$F{DNAME}]]></groupExpression>
</group>
<group name="LOC">
<groupExpression><![CDATA[$F{LOC}]]></groupExpression>
</group>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="145" splitType="Stretch">
<componentElement>
<reportElement positionType="FixRelativeToBottom" x="10" y="0" width="500" height="110" uuid="b37c89ae-600a-4fb8-ac64-e142bfe22e13"/>
<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="Dataset1" uuid="8f84378b-9508-4763-8265-69e68c41febe">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="100" uuid="00a00921-f5fa-4352-924c-f0531c919f71">
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="100" height="30" uuid="d88580f8-05d2-4eb0-a098-00e877c58c39"/>
<text><![CDATA[DEPTNO]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="90" height="30" uuid="15fda94a-b686-4808-b55c-3e08a8e86187"/>
<textFieldExpression><![CDATA[$F{DEPTNO}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="140" uuid="72e58aec-00f1-4937-8600-b32a6010d4d6">
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="130" height="30" uuid="942c89ca-e914-4809-bb18-3b7065b413f7"/>
<text><![CDATA[DNAME]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="130" height="30" uuid="8b936e63-5f84-4fd7-b21c-8c08fb9550a5"/>
<textFieldExpression><![CDATA[$F{DNAME}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="140" uuid="f312cbac-4554-492c-928f-dd84b5a55d42">
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="120" height="30" uuid="ce385917-88aa-4e51-9cae-a7a142f78323"/>
<text><![CDATA[LOC]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="120" height="30" uuid="0e43f425-558c-4001-9c44-ca14798bcb75"/>
<textFieldExpression><![CDATA[$F{LOC}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
The solution to use a a group expression inside the subdatset works perfectly fine also in jasper reports v6+.
Example (built from code and data from this answer)
Adding groupExpression to the subDataset to break to new page every 2 records ($V{REPORT_COUNT}-1)/2)
<subDataset name="tableDataset" uuid="7a53770f-0350-4a73-bfc1-48a5f6386594">
<field name="User" class="java.lang.String"/>
<field name="Rep" class="java.math.BigDecimal"/>
<group name="pageBreakGroup" isStartNewPage="true">
<groupExpression><![CDATA[(int)(($V{REPORT_COUNT}-1)/2)]]></groupExpression>
</group>
</subDataset>
Expand code snippet for full code.
<?xml version="1.0" encoding="UTF-8"?>
<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="reputation" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a88bd694-4f90-41fc-84d0-002b90b2d73e">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="CVS"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="tableDataset" uuid="7a53770f-0350-4a73-bfc1-48a5f6386594">
<field name="User" class="java.lang.String"/>
<field name="Rep" class="java.math.BigDecimal"/>
<group name="pageBreakGroup" isStartNewPage="true">
<groupExpression><![CDATA[(int)(($V{REPORT_COUNT}-1)/2d)]]></groupExpression>
</group>
</subDataset>
<parameter name="displayRecordNumber" class="java.lang.Boolean">
<defaultValueExpression><![CDATA[true]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<title>
<band height="50">
<componentElement>
<reportElement key="table" style="table" x="0" y="0" width="555" height="47" uuid="76ab08c6-e757-4785-a43d-b65ad4ab1dd5"/>
<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="tableDataset" uuid="07e5f1c2-af7f-4373-b653-c127c47c9fa4">
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
</datasetRun>
<jr:column width="90" uuid="918270fe-25c8-4a9b-a872-91299cddbc31">
<printWhenExpression><![CDATA[$P{displayRecordNumber}]]></printWhenExpression>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="5cd6da41-01d5-4f74-99c2-06784f891d1e"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Record number]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="30" uuid="5fe48359-0e7e-44b2-93ac-f55404189832"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="7979d8a2-4e3c-42a7-9ff9-86f8e0b164bc">
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="61d5f1b6-7677-4511-a10c-1fb8a56a4b2a"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Username]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="30" uuid="a3cdb99d-3bf6-4c66-b50c-259b9aabfaef"/>
<box leftPadding="3" rightPadding="3"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{User}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="625e4e5e-5057-4eab-b4a9-c5b22844d25c">
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="e1c07cb8-a44c-4a8d-8566-5c86d6671282"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Reputation]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="30" rowSpan="1">
<textField pattern="#,##0">
<reportElement x="0" y="0" width="90" height="30" uuid="6be2d79f-be82-4c7b-afd9-0039fb8b3189"/>
<box leftPadding="3" rightPadding="3"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{Rep}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</title>
</jasperReport>
Result in JasperStudio version 6.2
As you can see 3 pages (2 records on each, total record count 5).

JasperReport iReport: JRException: Error retrieving field value from bean

I'm trying to understand how iReport works and how to create a simple jrxml file.
The report has a title and header and the data should be in a table. When I try to check how the report looks like using the preview button, I could see the title and header but not the table (Please note that I use that I clicked the "Use default value" for all fields). When I did not use the default value, I get this error.
Error filling print... net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : name
net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : name 
    at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:809) 
    at net.sf.jasperreports.components.table.fill.FillTableSubreport.prepareSubreport(FillTableSubreport.java:156) 
    at net.sf.jasperreports.components.table.fill.FillTable.prepare(FillTable.java:400) 
    at net.sf.jasperreports.engine.fill.JRFillComponentElement.prepare(JRFillComponentElement.java:151) 
Caused by: net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : name 
    at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:123) 
    at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getFieldValue(JRAbstractBeanDataSource.java:96) 
    at net.sf.jasperreports.engine.data.JRBeanCollectionDataSource.getFieldValue(JRBeanCollectionDataSource.java:109) 
Caused by: java.lang.NoSuchMethodException: Unknown property 'name' on class 'class java.lang.String' 
    at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1322) 
    at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:770) 
    at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:846) 
    at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:426) 
    at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:111) 
    ... 15 more  Print not filled. Try to use an EmptyDataSource...
I thought that maybe that problem has something to do with how I typed the data for List. Probably the format is wrong. This is how I typed the sample data
(myName, 5, Manila)
(Based on the screenshot, Is the format correct? I even tried enclosing it in a square bracket but I still get the same error.)
please note that I have 3 columns Name , Age , Address.
But in the error message I noticed this
Unknown property 'name' on class 'class java.lang.String' 
which makes me think that I did something wrong when I create the dataset. (Sorry if I used a wrong term).
Anyway, here's the xml generated by iReport.
<?xml version="1.0" encoding="UTF-8"?>
<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="firstReport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="597c0716-df6b-42ec-a7c8-863eb1b7174a">
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#7FFFD4">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFFFEA">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TH" mode="Opaque" backcolor="#7FFFD4">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#BFFFEA">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Table Dataset 2" uuid="208e382c-09df-484e-8d2d-a4eb4f4e48ba">
<field name="name" class="java.lang.String"/>
<field name="age" class="java.lang.String"/>
<field name="address" class="java.lang.String"/>
</subDataset>
<parameter name="companyName" class="java.lang.String"/>
<parameter name="date" class="java.util.Date"/>
<parameter name="bean" class="java.util.List"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="32" splitType="Stretch">
<staticText>
<reportElement x="182" y="0" width="184" height="25" uuid="fe64d4b4-efb1-4ed2-ae06-772728fc8b65"/>
<textElement>
<font fontName="Bookman Old Style" size="15" isBold="true"/>
</textElement>
<text><![CDATA[Chart Of Account List]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="58" splitType="Stretch">
<staticText>
<reportElement x="13" y="0" width="100" height="20" uuid="52ae4669-b47e-408c-aabc-e8f470a1d92b"/>
<text><![CDATA[Company]]></text>
</staticText>
<staticText>
<reportElement x="13" y="38" width="100" height="20" uuid="a27fe0e1-9fe6-423f-a006-46c51c7e3e5e"/>
<text><![CDATA[Date Exported]]></text>
</staticText>
<textField>
<reportElement x="113" y="0" width="100" height="20" uuid="1d600fa2-9de4-4999-9222-98a8bcb484f9"/>
<textFieldExpression><![CDATA[$P{companyName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="113" y="38" width="100" height="20" uuid="1147b818-90ae-4b41-a757-19a590db41d7"/>
<textFieldExpression><![CDATA[$P{date}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<componentElement>
<reportElement key="table 1" style="table 1" x="13" y="0" width="270" height="50" uuid="652523bf-b666-47bc-a1aa-fc20fb9e489a"/>
<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="Table Dataset 2" uuid="6fcb9950-2d3f-4752-b56d-df7bff1e6991">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{bean})]]></dataSourceExpression>
</datasetRun>
<jr:column width="90" uuid="ee62967c-3669-49fe-a70d-a588ae47439d">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="a0973bfe-815a-498e-8b25-c3320cfe0f62"/>
<text><![CDATA[Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="61d8309e-dd7d-4978-b171-9ae9144e2f5c"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="76a9e313-d134-420e-898b-7f5f444c4efb">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="f79fdf71-a673-4d3a-8e10-b986d99b8e9b"/>
<text><![CDATA[Age]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="e4342bed-af9c-4541-9e57-a24485d0a94d"/>
<textFieldExpression><![CDATA[$F{age}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="5c38c250-d74e-440c-93cb-3fef8ad38157">
<jr:columnHeader style="table 1_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="4656a074-f345-483a-971b-b00c95746ec0"/>
<text><![CDATA[Address]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 1_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20" uuid="f2cc3d1c-97ef-48c1-b6e4-a12acc4e67ad"/>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
</jasperReport>
1) What is wrong with the jrxml that I made? Did I supply a wrong formatted data to the table? Or there's just something wrong with how I did the report?
This was fixed by adding "new" keyword in the datasource expression. You will see datasource expression by right clicking table in the Report Inspector. "edit Table Datasource"

inserting break in table to print only 10 rows per page in jasper reports 3.7.2

I have a jasper code that prints report in a table format and the values for the report are passed from the java class during the run time and i am using jasper reports 3.7.2 jar to print the report. The jasper code is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<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="grouping_on_zipcode_basis" pageWidth="1400" pageHeight="750" orientation="Landscape" isIgnorePagination="true" columnWidth="1300" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" isFloatColumnFooter="true" >
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="ireport.scriptlethandling" value="0"/>
<property name="ireport.encoding" value="UTF-8"/>
<import value="net.sf.jasperreports.engine.*"/>
<import value="java.util.*"/>
<import value="net.sf.jasperreports.engine.data.*"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" forecolor="#FFFFFF" backcolor="#006F3A">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#57A7E8">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
<conditionalStyle>
<conditionExpression><![CDATA[Boolean.valueOf($V{REPORT_COUNT}.intValue() % 2 == 0)]]></conditionExpression>
<style backcolor="#FFFFFF"/>
</conditionalStyle>
</style>
<subDataset name="tableDataset" >
<field name="participantName" class="java.lang.String"/>
<field name="Ssn" class="java.lang.String"/>
<field name="Zipcode" class="java.lang.String"/>
</subDataset>
<field name="Ssn" class="java.lang.String"/>
<field name="Zipcode" class="java.lang.String"/>
<background>
<band />
</background>
<title>
<band height="200">
<componentElement>
<reportElement key="table" style="table" x="146" y="150" width="299" height="46" isRemoveLineWhenBlank="true" />
<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="tableDataset">
<datasetParameter name="REPORT_DATA_SOURCE">
<datasetParameterExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></datasetParameterExpression>
</datasetParameter>
</datasetRun>
<jr:column width="90" >
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" />
<text><![CDATA[PARTICIPANT NAME]]></text></staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20" >
</reportElement>
<textFieldExpression><![CDATA[$F{participantName}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" >
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" >
<printWhenExpression><![CDATA[new Boolean($F{Ssn}!= null)]]></printWhenExpression>
</reportElement>
<text><![CDATA[SSN]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement isRemoveLineWhenBlank="true" x="0" y="0" width="90" height="20" />
<textFieldExpression><![CDATA[$F{Ssn}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" >
<printWhenExpression><![CDATA[new Boolean($F{Zipcode}!= null)]]></printWhenExpression>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" >
<printWhenExpression><![CDATA[new Boolean($F{Zipcode}!= null)]]></printWhenExpression>
</reportElement>
<text><![CDATA[ZIPCODE]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement isRemoveLineWhenBlank="true" x="0" y="0" width="90" height="20" />
<textFieldExpression><![CDATA[$F{participantZip}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</title>
<columnFooter>
<band />
</columnFooter>
<pageFooter>
<band />
</pageFooter>
<summary>
<band />
</summary>
</jasperReport>
Now i want to print only 10 rows per table and the upcoming values must be print on a new table in the next page and it goes on. But all the tables must contain only 10 rows. Please help me..!
I found a way. We can insert a column break at the end of the detail cell with a "print when expression". The code is as follows:
<jr:detailCell style="table_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="18"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{participantName}]]></textFieldExpression>
</textField>
<break type="Column">
<reportElement x="0" y="19" width="90" height="1">
<printWhenExpression><![CDATA[new java.lang.Boolean((int)($V{REPORT_COUNT}.intValue())%10==0)]]></printWhenExpression>
</reportElement>
</break>
</jr:detailCell>

What is the reason of getting empty report with jdbc datasource? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am using iReport 4.7.0. To get report in table format I am connecting to SQL Server 2005.
I am creating a dataset while designing a table that gives me a field values which are in database table but after complete design while I am previewing my jrxml file it doesn't show me a table with values.
I want to know what is the problem.
My jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<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="Test" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="09817b9b-055f-4d9f-b22e-85b7fac3d81e" whenNoDataType="AllSectionsNoDetail">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="35"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
<style backcolor="#EFF7FF"/>
</conditionalStyle>
</style>
<subDataset name="New Dataset 1" uuid="9bfe7683-aa43-4113-b4a6-8007d4c7ff5d">
<queryString language="SQL">
<![CDATA[select * from employee]]>
</queryString>
<field name="id" class="java.lang.Integer"/>
<field name="first_name" class="java.lang.String"/>
<field name="last_name" class="java.lang.String"/>
<field name="salary" class="java.lang.Integer"/>
<group name="id">
<groupExpression><![CDATA[$F{id}]]></groupExpression>
</group>
<group name="first_name">
<groupExpression><![CDATA[$F{first_name}]]></groupExpression>
</group>
<group name="last_name">
<groupExpression><![CDATA[$F{last_name}]]></groupExpression>
</group>
</subDataset>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<staticText>
<reportElement uuid="3f6a40c5-cb7c-4237-8635-19aab55cef63" x="205" y="16" width="100" height="20"/>
<textElement>
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Test Database]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<detail>
<band height="125" splitType="Stretch">
<componentElement>
<reportElement uuid="6dc5bcfb-b281-4ec4-a611-4e5b602031ed" key="table" style="table" x="16" y="10" width="527" height="115"/>
<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="New Dataset 1" uuid="ba8de9b8-6e5b-4178-a62d-380ec6e268c2">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column uuid="8a09f431-ce9d-4c86-bde8-b6eba830a10f" width="90">
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement uuid="05cb64bd-b18c-4323-9365-ed6fa5d763ae" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[id]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_CH" height="31" rowSpan="1"/>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement uuid="2fb15323-2f8b-4234-ae0b-7272676180df" x="0" y="0" width="90" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="db3eb7e3-b13d-4dff-b4cf-c64aa06853f2" width="90">
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement uuid="d60ed209-0e4f-4e66-8a4b-53a117a4fdf2" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[first_name]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_CH" height="31" rowSpan="1"/>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement uuid="4dc05d21-5b86-4da2-b64f-9f83666e1948" x="0" y="0" width="90" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{first_name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="1bdd10f7-b718-4fbc-9fca-9f0a7883dc5c" width="90">
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement uuid="2bdbbd7d-f990-4261-9243-6b0f9f7feb7b" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[last_name]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_CH" height="31" rowSpan="1"/>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement uuid="d361d452-b63c-47ff-a2de-33b3f6bebe9c" x="0" y="0" width="90" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{last_name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="da448dd2-72b0-4e70-92f8-0343fa894cc0" width="90">
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement uuid="388b140a-53d8-4097-b483-007767ab3494" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[salary]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_CH" height="31" rowSpan="1"/>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement uuid="25c5ca88-39e2-4ea2-abd7-d1afe2df4ed9" x="0" y="0" width="90" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{salary}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch">
<line>
<reportElement uuid="e22bf754-66e2-4993-9e24-93ef1cfadaaa" x="0" y="44" width="555" height="1"/>
</line>
</band>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch">
<textField>
<reportElement uuid="94fcb4b3-e6da-4603-a6f1-f10063aee62e" x="409" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
I think that your Detail band is not printed (your report's property When No Data has All Sections, No Detail value) because your main dataset is empty (I did not find in your template any others datasets except the New Dataset 1 subdataset).
You can move (put) your Table component to the Title band, for example.
You can find the sample of using Table component here.

How to create Jasper Report Table component with Group By?

The standard column layout can use to achieve this. How can I do it for the table component layout?
It is quite easy. You should add new datasource for Table component and then use it (datasource) in this component.
The sample jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ... whenNoDataType="AllSectionsNoDetail" ...>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="tableDataset">
<queryString language="SQL">
<![CDATA[SELECT id, city, street FROM address ORDER BY city]]>
</queryString>
<field name="ID" class="java.lang.Integer"/>
<field name="CITY" class="java.lang.String"/>
<field name="STREET" class="java.lang.String"/>
<group name="CITY">
<groupExpression><![CDATA[$F{CITY}]]></groupExpression>
</group>
</subDataset>
<title>
<band height="58" splitType="Stretch">
<componentElement>
<reportElement key="table" style="table" x="0" y="0" width="299" height="46"/>
<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="tableDataset">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="90">
<jr:groupHeader groupName="CITY">
<jr:cell height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="30"/>
<textElement/>
<textFieldExpression><![CDATA[$F{CITY}]]></textFieldExpression>
</textField>
</jr:cell>
</jr:groupHeader>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[Id]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[Street]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{STREET}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</title>
</jasperReport>
The design in iReport looks like this:
The main report view:
The Table component view:
In this sample I've delete the main datasource and put the Table component to the Title band. I've set whenNoDataType="AllSectionsNoDetail" property for displaying report.
The data in report is grouped by city field.