Jump to content
We've recently updated our Privacy Statement, available here ×

Jaspersoft studio json data adapter book or subreport document is Empty


disconnected.kay

Recommended Posts

I am trying to do something really simple yet after searching for the past few days I could not find an answer, I need some help on this one.

What I am trying to do:
I have multiple reports so A4 portrait some landscape, some with just static text some with tables, some with tables and variables and I want to put merge them together. 

They work 100% individually.

Tried to make a master report with subreports did not work, tried the book approach did not work, I always get Document is empty, or if I try to manipulate the data query I get all kind of weird stuff. 

Now I will try to make this example as simple as possible.


JSON data: (New data Adapter)

    {      "name": "Sample Name",      "people":[        {          "who": "Person 1"        },        {          "who": "Person 2"        },        {          "who": "Person 3"        }      ]    }[/code]


Book master report:

    <?xml version="1.0" encoding="UTF-8"?>    <!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  -->    <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" 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="New Data Adapter "/>        <property name="net.sf.jasperreports.print.create.bookmarks" value="true"/>        <queryString language="json">            <![CDATA[]]>        </queryString>        <detail>            <part uuid="69d6ca13-26f6-425f-bff9-395c5b9c183b">                <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>                    <subreportExpression><![CDATA["Blank_A4_2.jasper"]]></subreportExpression>                </p:subreportPart>            </part>            <part uuid="055c9f89-88b4-4270-b6ef-addb2eac3e56">                <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>                    <subreportExpression><![CDATA["Blank_A4_Landscape_1.jasper"]]></subreportExpression>                </p:subreportPart>            </part>        </detail>    </jasperReport>[/code]

Blank_A4_2.jrxml

  <?xml version="1.0" encoding="UTF-8"?>    <!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  -->    <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_2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="bd2bd70c-5a0d-4c3f-b81d-4d5d7731153d">        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/>        <queryString language="json">            <![CDATA[]]>        </queryString>        <field name="name" class="java.lang.String">            <property name="net.sf.jasperreports.json.field.expression" value="name"/>            <fieldDescription><![CDATA[name]]></fieldDescription>        </field>        <background>            <band splitType="Stretch"/>        </background>        <detail>            <band height="125" splitType="Stretch">                <textField>                    <reportElement x="150" y="30" width="100" height="30" uuid="eef5f1dc-3d96-4008-8321-ef0be92d42d4"/>                    <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>                </textField>                <staticText>                    <reportElement x="50" y="30" width="100" height="30" uuid="cbe6173f-5399-45ec-926b-ff6f48b4fb0c"/>                    <text><![CDATA[name]]></text>                </staticText>            </band>        </detail>    </jasperReport>[/code]


Blank_A4_Landscape_1.jrxml

 <?xml version="1.0" encoding="UTF-8"?>    <!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  -->    <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_Landscape_1" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="62f06d09-42b5-4471-baa5-5aed60cc5fc4">        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/>        <subDataset name="Dataset1" uuid="eb54ec0d-0c60-44af-8476-e44f40560dee">            <property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/>            <queryString language="json">                <![CDATA[people]]>            </queryString>            <field name="who" class="java.lang.String">                <property name="net.sf.jasperreports.json.field.expression" value="who"/>                <fieldDescription><![CDATA[who]]></fieldDescription>            </field>        </subDataset>        <queryString language="JSON">            <![CDATA[]]>        </queryString>        <field name="name" class="java.lang.String">            <property name="net.sf.jasperreports.json.field.expression" value="name"/>            <fieldDescription><![CDATA[name]]></fieldDescription>        </field>        <background>            <band splitType="Stretch"/>        </background>        <columnHeader>            <band height="175">                <textField>                    <reportElement x="132" y="81" width="100" height="30" uuid="5cce1f44-2a8b-42ad-a03d-4c294f02d31c"/>                    <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>                </textField>            </band>        </columnHeader>        <detail>            <band height="140" splitType="Stretch">                <componentElement>                    <reportElement x="110" y="45" width="200" height="40" uuid="75a06812-f9a0-4b0f-9a08-efec60d0b555"/>                    <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="acd62160-c07c-4c00-b6b4-9ef001d1585d">                            <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("people")]]></dataSourceExpression>                        </datasetRun>                        <jr:column width="200" uuid="253a610c-a780-4690-8cce-8a03597ef016">                            <jr:detailCell height="30">                                <textField>                                    <reportElement x="0" y="0" width="200" height="30" uuid="910a7e24-c02b-4b21-8c9d-6a3dfda21794"/>                                    <textFieldExpression><![CDATA[$F{who}]]></textFieldExpression>                                </textField>                            </jr:detailCell>                        </jr:column>                    </jr:table>                </componentElement>            </band>        </detail>    </jasperReport>[/code]

Tested all files before posting, individually they work, I have no params to send to the subreports, I tried looping over the array and still nothing I always get document is Empty no matter what I do.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...