Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jasper reports JasperReports:JRDataSource.subDataSource显示未定义_Jasper Reports_Subreport_Xmldatasource - Fatal编程技术网

Jasper reports JasperReports:JRDataSource.subDataSource显示未定义

Jasper reports JasperReports:JRDataSource.subDataSource显示未定义,jasper-reports,subreport,xmldatasource,Jasper Reports,Subreport,Xmldatasource,我正在使用iReport创建我的报告 我已经使用上面提到的指南创建了两个报告。 但是在一个新的报告中,当我设置ListComponent的DataSource时,Jasper向我报告以下错误: 对于类型jrdasource value=((net.sf.jasperreports.engine.jrdasource)参数_REPORT_DATA_SOURCE.getValue()).subDataSource(“/items/invoices”)未定义方法subDataSource(String

我正在使用iReport创建我的报告

我已经使用上面提到的指南创建了两个报告。 但是在一个新的报告中,当我设置
ListComponent的
DataSource
时,Jasper向我报告以下错误:

对于类型jrdasource value=((net.sf.jasperreports.engine.jrdasource)参数_REPORT_DATA_SOURCE.getValue()).subDataSource(“/items/invoices”)未定义方法subDataSource(String);//$JR\u EXPR\u ID=11$

我试着在文档中查找,它确实提到
jrdasource
没有任何这样的方法。但是,我之前已经学习了本教程并做了报告

这是我遇到的报告的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="product-wise-sales-analysis" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a8a1a939-18a1-4ecf-8c4c-9f7b556b5ce3">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <subDataset name="invoices" uuid="9d9c4386-0f01-4f9f-9b17-12906b566f63">
        <queryString language="xPath">
            <![CDATA[/data/items/invoices]]>
        </queryString>
        <field name="invoiceId" class="java.lang.String">
            <fieldDescription><![CDATA[invoiceId]]></fieldDescription>
        </field>
        <field name="salesInvoiceDate" class="java.lang.String">
            <fieldDescription><![CDATA[salesInvoiceDate]]></fieldDescription>
        </field>
        <field name="partyName" class="java.lang.String">
            <fieldDescription><![CDATA[partyName]]></fieldDescription>
        </field>
        <field name="quantity" class="java.lang.String">
            <fieldDescription><![CDATA[quantity]]></fieldDescription>
        </field>
        <field name="rate" class="java.lang.String">
            <fieldDescription><![CDATA[rate]]></fieldDescription>
        </field>
    </subDataset>
    <queryString language="xPath">
        <![CDATA[/data/items]]>
    </queryString>
    <field name="productCatlgNo" class="java.lang.String">
        <fieldDescription><![CDATA[productCatlgNo]]></fieldDescription>
    </field>
    <field name="description" class="java.lang.String">
        <fieldDescription><![CDATA[description]]></fieldDescription>
    </field>
    <field name="groupName" class="java.lang.String">
        <fieldDescription><![CDATA[groupName]]></fieldDescription>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="23" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="2" width="100" height="20" uuid="b14d57a3-c78e-4121-ac21-955b4ab431f0"/>
                <text><![CDATA[productCatlgNo]]></text>
            </staticText>
            <staticText>
                <reportElement x="147" y="2" width="100" height="20" uuid="c009d720-b224-4595-9761-89447d437dc3"/>
                <text><![CDATA[description]]></text>
            </staticText>
            <staticText>
                <reportElement x="341" y="0" width="100" height="20" uuid="f22f2f3f-885e-4ffd-bd2f-b69025a46c2d"/>
                <text><![CDATA[groupName]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="34" splitType="Stretch">
            <textField>
                <reportElement x="147" y="0" width="194" height="12" uuid="383b8740-6b4d-4ddd-9e85-6aa45a08c464"/>
                <textFieldExpression><![CDATA[$F{description}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="0" width="147" height="12" uuid="ebd965f4-5684-49b8-8ed4-e11e43d64230"/>
                <textFieldExpression><![CDATA[$F{productCatlgNo}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="341" y="0" width="209" height="12" uuid="4b98a152-6c2e-4335-835a-9288c179df5a"/>
                <textFieldExpression><![CDATA[$F{groupName}]]></textFieldExpression>
            </textField>
            <componentElement>
                <reportElement x="0" y="12" width="555" height="21" uuid="786c54cf-6dc1-4daf-a174-694c24cfd27b"/>
                <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">
                    <datasetRun subDataset="invoices" uuid="c61741af-4e58-4bb6-a18b-468a29c02b14">
                        <dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}.subDataSource("/items/invoices")]]></dataSourceExpression>
                    </datasetRun>
                    <jr:listContents height="21" width="555">
                        <textField>
                            <reportElement x="5" y="0" width="100" height="20" uuid="c3923524-ac87-4a59-a4d0-89d4c6ade197"/>
                            <textFieldExpression><![CDATA[$F{invoiceId}]]></textFieldExpression>
                        </textField>
                    </jr:listContents>
                </jr:list>
            </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>

你知道为什么会这样吗?

我想出来了

出于某种原因,我不得不将
ListComponent
DataSource
转换为
JRXmlDataSource
对象。(我在以前的报告中没有做过这个角色)

因此,ListComponent中数据源的表达式为:

((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/items/invoices")
而不是:

$P{REPORT_DATA_SOURCE}).subDataSource("/items/invoices")