Jasper Book is empty.

0

I have two reports, Report1.jrxml and Report2.jrxml.  Both reports work when run individually. 

I have specified  whenNoDataType="AllSectionsNoDetail" so that I will get the header even with an empty dataset.  This works with both reports when run alone.

Now I want to run them together so I created a book and added both reports to the book.  I pass the JRDataSource to each report, but even if I did not I should still get the header.  However I get nothing, just an empty PDF returned.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1  -->
<!-- 2017-06-19T11:10:26 -->
<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="Empty_Book" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" sectionType="Part" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30" 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"/>
    <parameter name="Report1DataSource" class="net.sf.jasperreports.engine.JRDataSource"/>
    <parameter name="Report2DataSource" class="net.sf.jasperreports.engine.JRDataSource"/>
    <parameter name="company" class="java.lang.String"/>
    <parameter name="address1" class="java.lang.String"/>
    <parameter name="address2" class="java.lang.String"/>
    <parameter name="city" class="java.lang.String"/>
    <parameter name="state" class="java.lang.String"/>
    <parameter name="zip" class="java.lang.String"/>
    <parameter name="phone" class="java.lang.String"/>
    <parameter name="fax" class="java.lang.String"/>
    <parameter name="website" class="java.lang.String"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <detail>
        <part evaluationTime="Now" uuid="1ee53675-d742-4aed-8bc3-7b67af20545e">
            <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_CONNECTION">
                    <subreportParameterExpression><![CDATA[$P{REPORT_CONNECTION}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="REPORT_DATA_SOURCE">
                    <subreportParameterExpression><![CDATA[$P{Report1DataSource}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="company">
                    <subreportParameterExpression><![CDATA[$P{company}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="address1">
                    <subreportParameterExpression><![CDATA[$P{address1}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="address2">
                    <subreportParameterExpression><![CDATA[$P{address2}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="city">
                    <subreportParameterExpression><![CDATA[$P{city}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="state">
                    <subreportParameterExpression><![CDATA[$P{state}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="zip">
                    <subreportParameterExpression><![CDATA[$P{zip}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="phone">
                    <subreportParameterExpression><![CDATA[$P{phone}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="fax">
                    <subreportParameterExpression><![CDATA[$P{fax}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="website">
                    <subreportParameterExpression><![CDATA[$P{website}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportExpression><![CDATA["src/com/castit/reports/templates/qualitycontrol/nondestructivetesting/FpiTechnique.jasper"]]></subreportExpression>
            </p:subreportPart>
        </part>
        <part uuid="d3162c3a-5eba-45b7-9d48-800f5dddfc75">
            <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_CONNECTION">
                    <subreportParameterExpression><![CDATA[$P{REPORT_CONNECTION}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="REPORT_DATA_SOURCE">
                    <subreportParameterExpression><![CDATA[$P{Report2DataSource}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="company">
                    <subreportParameterExpression><![CDATA[$P{company}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="address1">
                    <subreportParameterExpression><![CDATA[$P{address1}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="address2">
                    <subreportParameterExpression><![CDATA[$P{address2}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="city">
                    <subreportParameterExpression><![CDATA[$P{city}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="state">
                    <subreportParameterExpression><![CDATA[$P{state}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="zip">
                    <subreportParameterExpression><![CDATA[$P{zip}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="phone">
                    <subreportParameterExpression><![CDATA[$P{phone}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="fax">
                    <subreportParameterExpression><![CDATA[$P{fax}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="website">
                    <subreportParameterExpression><![CDATA[$P{website}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportExpression><![CDATA["src/com/castit/reports/templates/qualitycontrol/nondestructivetesting/FpiTechniqueWithImages.jasper"]]></subreportExpression>
            </p:subreportPart>
        </part>
    </detail>
</jasperReport>

Bob.Lawson's picture
Joined: Jan 26 2017 - 4:58am
Last seen: 1 month 4 weeks ago

1 Answer:

0

This is confused. You have a data source and a connection for your parts, but you should only have one of those.  If you're using the same connection as the main report, just use 

 <subreportParameterExpression><![CDATA[$P{REPORT_CONNECTION}]]></subreportParameterExpression> </subreportParameter>

You need to have separate jrxmls for your reports that you are putting in, and then reference them.

Take a look at the JasperReports sample file for books.

http://community.jaspersoft.com/wiki/jasperreports-library-samples

You can also install these samples in JSS, if you are using that.

elizam's picture
2106
Joined: Mar 5 2012 - 9:19am
Last seen: 1 day 20 hours ago
Feedback