Hi,
I am new to iReports. I am trying to create a sample report with a
sub-report. The parent and child reports are simple reports without any
datasource. They simply display some static text. When I run the parent
report I can only see the content of the parent report and not the child
report. Can any one help me with this problem? I am sending the two
templates I have used for the sample. Thanks in advance.
Venkat
<?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="Parent"
columnCount="1"
printOrder="Vertical"
orientation="Portrait"
pageWidth="595"
pageHeight="842"
columnWidth="535"
columnSpacing="0"
leftMargin="30"
rightMargin="30"
topMargin="20"
bottomMargin="20"
whenNoDataType="NoPages"
isTitleNewPage="false"
isSummaryNewPage="false">
<property name="ireport.scriptlethandling" value="0" />
<import value="java.util.*" />
<import value="net.sf.jasperreports.engine.*" />
<import value="net.sf.jasperreports.engine.data.*" />
<background>
<band height="0" isSplitAllowed="true" >
</band>
</background>
<title>
<band height="50" isSplitAllowed="true" >
<staticText>
<reportElement
mode="Opaque"
x="186"
y="7"
width="161"
height="36"
forecolor="#000000"
backcolor="#FFFFFF"
key="staticText-1"
stretchType="NoStretch"
positionType="FixRelativeToTop"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement textAlignment="Center" verticalAlignment="Top" rotation="None" lineSpacing="Single">
<font fontName="Arial" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" />
</textElement>
<text><![CDATA[Parent Report]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="50" isSplitAllowed="true" >
</band>
</pageHeader>
<columnHeader>
<band height="30" isSplitAllowed="true" >
</band>
</columnHeader>
<detail>
<band height="492" isSplitAllowed="true" >
<subreport isUsingCache="false">
<reportElement
mode="Opaque"
x="14"
y="13"
width="512"
height="475"
forecolor="#000000"
backcolor="#FFFFFF"
key="subreport-1"
stretchType="RelativeToBandHeight"
positionType="Float"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<subreportParameter name="company_name">
<subreportParameterExpression><![CDATA["from_parent"]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression class="java.lang.String"><![CDATA["Child.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<columnFooter>
<band height="30" isSplitAllowed="true" >
</band>
</columnFooter>
<pageFooter>
<band height="50" isSplitAllowed="true" >
</band>
</pageFooter>
<lastPageFooter>
<band height="50" isSplitAllowed="true" >
</band>
</lastPageFooter>
<summary>
<band height="50" isSplitAllowed="true" >
</band>
</summary>
</jasperReport>
<?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="Child"
columnCount="1"
printOrder="Vertical"
orientation="Landscape"
pageWidth="425"
pageHeight="283"
columnWidth="397"
columnSpacing="0"
leftMargin="14"
rightMargin="14"
topMargin="14"
bottomMargin="14"
whenNoDataType="NoPages"
isTitleNewPage="false"
isSummaryNewPage="false">
<property name="ireport.scriptlethandling" value="0" />
<import value="java.util.*" />
<import value="net.sf.jasperreports.engine.*" />
<import value="net.sf.jasperreports.engine.data.*" />
<parameter name="company_name" isForPrompting="true" class="java.lang.String">
<defaultValueExpression ><![CDATA["from_child"]]></defaultValueExpression>
</parameter>
<background>
<band height="96" isSplitAllowed="true" >
<staticText>
<reportElement
mode="Opaque"
x="26"
y="7"
width="349"
height="82"
forecolor="#000000"
backcolor="#9999FF"
key="staticText-2"
stretchType="NoStretch"
positionType="FixRelativeToTop"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement textAlignment="Center" verticalAlignment="Top" rotation="None" lineSpacing="Single">
<font fontName="Arial" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" />
</textElement>
<text><![CDATA[]]></text>
</staticText>
</band>
</background>
<title>
<band height="20" isSplitAllowed="true" >
</band>
</title>
<pageHeader>
<band height="22" isSplitAllowed="true" >
</band>
</pageHeader>
<columnHeader>
<band height="21" isSplitAllowed="true" >
</band>
</columnHeader>
<detail>
<band height="23" isSplitAllowed="true" >
<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
mode="Opaque"
x="120"
y="6"
width="168"
height="12"
forecolor="#000000"
backcolor="#CCCCFF"
key="textField"
stretchType="NoStretch"
positionType="FixRelativeToTop"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement textAlignment="Center" verticalAlignment="Top" rotation="None" lineSpacing="Single">
<font fontName="Arial" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" />
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{company_name}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="26" isSplitAllowed="true" >
</band>
</columnFooter>
<pageFooter>
<band height="24" isSplitAllowed="true" >
</band>
</pageFooter>
<lastPageFooter>
<band height="25" isSplitAllowed="true" >
</band>
</lastPageFooter>
<summary>
<band height="29" isSplitAllowed="true" >
</band>
</summary>
</jasperReport>