Getting data in subreport

To start with, I first checked the subreport that came with JasperReport's documentation which got me thus far. I am setting a Map of that contains multiple Lists wrapped in a class that implements JRDataSource for my detail.

My main report is displaying just fine. Using the id in the main report I want to call the get() on the Map to return the JRDataSource Object to pass to the detail report to display. The error I'm receiving is:
Error evaluating expression : Source text : $P{WEEK_STATUS_DTL_DATA}.get($F{id})

WEEK_STATUS_DTL_DATA is a Map of DataSource Objects

Here is my main report:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created using JasperAssistant (http://www.jasperassistant.com) -->
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

<jasperReport name="weekStatusHdr" pageWidth="791" pageHeight="612" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="771" leftMargin="10" rightMargin="10" topMargin="10" bottomMargin="10">
<property name="com.jasperassistant.designer.Grid" value="true"/>
<property name="com.jasperassistant.designer.SnapToGrid" value="true"/>
<property name="com.jasperassistant.designer.GridWidth" value="4"/>
<property name="com.jasperassistant.designer.GridHeight" value="4"/>
<property name="com.jasperassistant.designer.Margins" value="true"/>
<property name="com.jasperassistant.designer.Rulers" value="true"/>
<property name="com.jasperassistant.designer.SnapToGuides" value="true"/>
<property name="com.jasperassistant.designer.DataSource" value="WebPromoHdr"/>
<property name="com.jasperassistant.designer.VGuides.Column Header" value="3,6"/>
<reportFont name="Header" isDefault="false" fontName="Times New Roman" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Times-Bold" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
<reportFont name="Detail" isDefault="false" fontName="Times New Roman" size="9" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Times-Roman" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
<parameter name="pitPromWeek" class="com.peapod.newton.model.PitPromWeek"/>
<parameter name="WEEK_STATUS_DTL_DATA" class="java.util.HashMap"/>
<parameter name="WEEK_STATUS_DTL_RPT" class="net.sf.jasperreports.engine.JasperReport"/>
<field name="id" class="java.lang.Integer"/>
<field name="pitPromHdr" class="app.web.promo.model.PitPromHdr"/>
<field name="weekErr" class="app.web.promo.model.dto.WeekErr"/>
<title>
<band height="65">
<staticText>
<reportElement x="4" y="4" width="765" height="37"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="26"/>
</textElement>
<text><![CDATA[Promotion Week Status
]]></text>
</staticText>
<textField>
<reportElement x="8" y="40" width="761" height="21"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{pitPromWeek}.getWeekLongDescription() + " - " + $P{pitPromWeek}.getCurrStatCd()]]></textFieldExpression>
</textField>
<line>
<reportElement x="4" y="64" width="765" height="1"/>
<graphicElement/>
</line>
</band>
</title>
<columnHeader>
<band height="21">
<staticText>
<reportElement x="12" y="8" width="29" height="13"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font reportFont="Header" fontName="Times New Roman" isBold="true" isUnderline="false" isPdfEmbedded="false"/>
</textElement>
<text><![CDATA[
Prom ID
]]></text>
</staticText>
<staticText>
<reportElement x="40" y="8" width="169" height="13"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font reportFont="Header" fontName="Times New Roman" isBold="true" isUnderline="false" isPdfEmbedded="false"/>
</textElement>
<text><![CDATA[
Description
]]></text>
</staticText>
<staticText>
<reportElement x="220" y="8" width="49" height="13"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font reportFont="Header" fontName="Times New Roman" isBold="true" isUnderline="false" isPdfEmbedded="false"/>
</textElement>
<text><![CDATA[
Sale Type
]]></text>
</staticText>
<staticText>
<reportElement x="276" y="8" width="53" height="13"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font reportFont="Header" fontName="Times New Roman" isBold="true" isUnderline="false" isPdfEmbedded="false"/>
</textElement>
<text><![CDATA[
Prom Type
]]></text>
</staticText>
<staticText>
<reportElement x="392" y="8" width="169" height="13"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font reportFont="Header" fontName="Times New Roman" isBold="true" isUnderline="false" isPdfEmbedded="false"/>
</textElement>
<text><![CDATA[
Issue
]]></text>
</staticText>
<staticText>
<reportElement x="584" y="8" width="169" height="13"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font reportFont="Header" fontName="Times New Roman" isBold="true" isUnderline="false" isPdfEmbedded="false"/>
</textElement>
<text><![CDATA[
Detail
]]></text>
</staticText>
<line>
<reportElement x="4" y="20" width="765" height="1"/>
<graphicElement/>
</line>
<staticText>
<reportElement x="336" y="8" width="53" height="13"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font reportFont="Header" fontName="Times New Roman" isBold="true" isUnderline="false" isPdfEmbedded="false"/>
</textElement>
<text><![CDATA[
Ignorable?
]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20">
<textField>
<reportElement x="12" y="4" width="29" height="13"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font reportFont="Detail" fontName="Times New Roman"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[Integer.toString($F{pitPromHdr}.getPromId())]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="40" y="5" width="169" height="12"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font reportFont="Detail" fontName="Times New Roman"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{pitPromHdr}.getPromDescTx()]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="220" y="5" width="49" height="13"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font reportFont="Detail" fontName="Times New Roman"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{pitPromHdr}.getSaleTypeCd()]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="276" y="4" width="53" height="13"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font reportFont="Detail" fontName="Times New Roman"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{pitPromHdr}.getPromTypeCd()]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="392" y="4" width="169" height="13"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font reportFont="Detail" fontName="Times New Roman"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{weekErr}.getErrTx()]]></textFieldExpression>
</textField>
<rectangle>
<reportElement x="0" y="8" width="9" height="9"/>
<graphicElement/>
</rectangle>
<textField>
<reportElement x="337" y="4" width="52" height="13"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font reportFont="Detail"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{weekErr}.getIgnrCd()]]></textFieldExpression>
</textField>
<textField>
<reportElement x="564" y="4" width="13" height="13"/>
<textElement textAlignment="Right">
<font reportFont="Detail"/>
</textElement>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{id}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="584" y="3" width="185" height="14"/>
<subreportParameter name="id">
<subreportParameterExpression>
<![CDATA[$P{WEEK_STATUS_DTL_DATA}.get($F{id})]]>
</subreportParameterExpression>
</subreportParameter>
<dataSourceExpression>
<![CDATA[$P{WEEK_STATUS_DTL_DATA}.get($F{id})]]>
</dataSourceExpression>
<subreportExpression class="net.sf.jasperreports.engine.JasperReport">
<![CDATA[$P{WEEK_STATUS_DTL_RPT}]]>
</subreportExpression>

</subreport>
</band>
</detail>
<pageFooter>
<band height="16">
<textField pattern="M/d/yy h:mm:ss a">
<reportElement x="0" y="4" width="161" height="12"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font reportFont="Header" fontName="Times New Roman"/>
</textElement>
<textFieldExpression class="java.util.Date"><![CDATA[new Date()]]></textFieldExpression>
</textField>
<textField>
<reportElement x="662" y="4" width="85" height="12"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font reportFont="Header"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["Page " +$V{PAGE_NUMBER}.toString() + " of "]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="748" y="4" width="22" height="12"/>
<textElement verticalAlignment="Middle">
<font reportFont="Header"/>
</textElement>
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="3" width="770" height="1"/>
<graphicElement/>
</line>
</band>
</pageFooter>
</jasperReport>



And my detail report:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created using JasperAssistant (http://www.jasperassistant.com) -->
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

<jasperReport name="weekStatusDtl" pageWidth="612" pageHeight="791" whenNoDataType="BlankPage" columnWidth="612" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
<property name="com.jasperassistant.designer.DataSource" value="WebPromoDtl"/>
<property name="com.jasperassistant.designer.Grid" value="true"/>
<property name="com.jasperassistant.designer.SnapToGrid" value="false"/>
<property name="com.jasperassistant.designer.GridWidth" value="4"/>
<property name="com.jasperassistant.designer.GridHeight" value="4"/>
<property name="com.jasperassistant.designer.Margins" value="true"/>
<property name="com.jasperassistant.designer.Rulers" value="true"/>
<property name="com.jasperassistant.designer.SnapToGuides" value="true"/>
<reportFont name="DtlErr" isDefault="false" fontName="Times New Roman" size="9" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Times-Roman" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
<parameter name="dataSource" class="java.lang.String"/>
<field name="dtlErrTx" class="java.lang.String"/>
<field name="dtlId" class="java.lang.Integer"/>
<field name="promLvlCd" class="java.lang.String"/>
<detail>
<band height="22">
<textField>
<reportElement x="6" y="0" width="513" height="20"/>
<textElement>
<font reportFont="DtlErr"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{dtlErrTx}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>



Thanks for ANY insight that you can give as to why I cannot reference the DataSource from the Map.
Hi,

Please check the log file for the full error message and stacktrace. You can also use the "Error Log" view provided by Eclipse. The log file location is <workspace>/.metadata/.log


I hope this helps,

Peter Severin
- JasperAssistant Team
I wanted to post the fact that this was my fault. My detail data list was NOT wrapped in a JRDataSource. Once I did this all worked well.

Sorry for the bad post.
Could you please post your code as to how you populated your datasource and filled the report.
This topic is archived Other recent topics