hanlie Posted November 29, 2006 Share Posted November 29, 2006 I know this is a common problem, but I can't see the error in my code and I was hoping someone here could help me. The master report (DateMsisdnMasterReport) should get an MSISDN from the database and then pass it to the subreport (DateMsisdnSubReport). The subreport must then retrieve all the dates of entries in the database for this MSISDN. When I run the subreport by itself and manually pass it an MSISDN, it works perfectly. BUT... as soon as I try to run the subreport from the master report, I get a report with the text "null" where the records should be. Both reports are in the directory Code:c:javajaspertemplates on my computer and I made sure that I compiled the subreport to a .jasper file before I tried to print the master report. My master report is here: Code:[code]<?xml version="1.0" encoding="UTF-8" ?><!-- Created with iReport - A designer for JasperReports --><!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"><jasperReport name="DateMsisdnMasterReport" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="555" columnSpacing="0" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <parameter name="msisdn" isForPrompting="false" class="java.lang.String"/> <parameter name="subreportPath" isForPrompting="false" class="java.lang.String"> <defaultValueExpression ><![CDATA["C:\java\jasper\templates\"]]></defaultValueExpression> </parameter> <queryString><![CDATA[select distinct msisdn from entry]]></queryString> <field name="msisdn" class="java.lang.String"/> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="30" isSplitAllowed="true" > <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="300" height="24" key="textField"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement isStyledText="true"> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["<style isBold="true" pdfFontName="Helvetica-Bold">Entries for " + $P{msisdn} + "</style>"]]></textFieldExpression> </textField> </band> </title> <pageHeader> <band height="0" isSplitAllowed="true" > </band> </pageHeader> <columnHeader> <band height="0" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="10" isSplitAllowed="true" > <subreport isUsingCache="false"> <reportElement x="0" y="0" width="500" height="10" key="subreport" isPrintWhenDetailOverflows="true"/> <subreportParameter name="msisdn"> <subreportParameterExpression><![CDATA[$P{msisdn}]]></subreportParameterExpression> </subreportParameter> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression class="java.lang.String"><![CDATA[$P{subreportPath} + "/DateMsisdnSubReport.jasper"]]></subreportExpression> </subreport> </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="0" isSplitAllowed="true" > </band> </pageFooter> <summary> <band height="0" isSplitAllowed="true" > </band> </summary></jasperReport> And my subreport is here: Code:[code]<?xml version="1.0" encoding="UTF-8" ?><!-- Created with iReport - A designer for JasperReports --><!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"><jasperReport name="DateMsisdnSubReport" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="555" columnSpacing="0" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <style name="Times" isDefault="false" leftPadding="4" fontName="Times New Roman" fontSize="11" pdfFontName="Times-Roman" isPdfEmbedded="true" /> <style name="TimesBold" isDefault="false" leftPadding="4" fontName="Times New Roman" fontSize="11" isBold="true" pdfFontName="Times-Bold" /> <parameter name="msisdn" isForPrompting="false" class="java.lang.String"/> <queryString><![CDATA[select to_char(entry.date,'YYYY-MM-DD HH24:MI:«»SS') as date from entry where msisdn = $P{msisdn} order by date]]></queryString> <field name="date" class="java.lang.String"/> <variable name="row_count" class="java.lang.Integer" resetType="Report" calculation="Count"> <variableExpression><![CDATA[$F{date}]]></variableExpression> </variable> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="30" isSplitAllowed="true" > </band> </title> <pageHeader> <band height="30" isSplitAllowed="true" > <staticText> <reportElement style="TimesBold" x="201" y="6" width="98" height="22" key="staticText-1"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" leftPadding="4" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement> <font/> </textElement> <text><![CDATA[Dates & Times]]></text> </staticText> <staticText> <reportElement style="TimesBold" x="101" y="6" width="98" height="22" key="staticText-2"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" leftPadding="4" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement> <font/> </textElement> <text><![CDATA[Number of Entries]]></text> </staticText> <staticText> <reportElement style="TimesBold" x="3" y="8" width="98" height="22" key="staticText-3"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" leftPadding="4" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement> <font/> </textElement> <text><![CDATA[MSISDN]]></text> </staticText> </band> </pageHeader> <columnHeader> <band height="0" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="24" isSplitAllowed="true" > <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement style="Times" x="200" y="0" width="100" height="24" key="textField"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" leftPadding="4" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement verticalAlignment="Middle"> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{date}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement style="Times" x="0" y="1" width="102" height="22" key="textField-1" isPrintRepeatedValues="false"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" leftPadding="4" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$P{msisdn}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" isBlankWhenNull="true" evaluationTime="Report" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement style="Times" x="103" y="2" width="95" height="20" key="textField-2" isPrintRepeatedValues="false"> <printWhenExpression><![CDATA[new Boolean((($V{row_count}.intValue())== 1))]]></printWhenExpression> </reportElement> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" leftPadding="4" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement> <font/> </textElement> <textFieldExpression class="java.lang.Integer"><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="0" isSplitAllowed="true" > </band> </pageFooter> <summary> <band height="0" isSplitAllowed="true" > </band> </summary></jasperReport> ThanksHanlie Post edited by: hanlie, at: 2006/11/29 11:38Post edited by: hanlie, at: 2006/11/29 11:41 Link to comment Share on other sites More sharing options...
hanlie Posted November 29, 2006 Author Share Posted November 29, 2006 I've found the error woohoo! I passed $P{msisdn} to the subreport and I should have passed $F{msisdn}. It's working now. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now