Jump to content
Changes to the Jaspersoft community edition download ×

SubReport, need help to understand


ktrinad

Recommended Posts

By: Simon Chevrier - simonchevrier

SubReport, need help to understand

2003-04-30 11:30

 

 

Hi,

 

IÂ’m newbie with ireport. I work with the ireport version 0.1.0

I use the exemple of Giulio(2003-02-28 14:16) to create a test with subreport.

 

Here my code exemple:

 

MasterReport:

 

<?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="MasterReport"

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">

<parameter name="SUBREPORT_FILE_NAME" isForPrompting="true" class="java.lang.String">

<defaultValueExpression><![CDATA[C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper]]></defaultValueExpression>

</parameter>

<queryString><![CDATA[sELECT * FROM employee]]></queryString>

<field name="ID" class="java.lang.String"/>

<field name="first_name" class="java.lang.String"/>

<field name="last_name" class="java.lang.String"/>

<background>

<band height="50">

</band>

</background>

<title>

<band height="50">

</band>

</title>

<pageHeader>

<band height="50">

<staticText>

<reportElement

mode="Transparent"

x="7"

y="11"

width="164"

height="31"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<text>Master Report</text>

</staticText>

</band>

</pageHeader>

<columnHeader>

<band height="30">

<staticText>

<reportElement

mode="Transparent"

x="20"

y="3"

width="101"

height="24"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<text>ID</text>

</staticText>

<staticText>

<reportElement

mode="Transparent"

x="276"

y="5"

width="160"

height="25"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<text>Name</text>

</staticText>

</band>

</columnHeader>

<detail>

<band height="87">

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="18"

y="4"

width="102"

height="22"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String">$F{ID}</textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="228"

y="5"

width="296"

height="24"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{first_name} + " " + $F{last_name}]]></textFieldExpression>

</textField>

<subreport isUsingCache="true">

<reportElement

mode="Opaque"

x="9"

y="31"

width="512"

height="35"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<subreportParameter name="ADDRESSID">

<subreportParameterExpression>$F{ID}</subreportParameterExpression>

</subreportParameter>

<connectionExpression>$P{REPORT_CONNECTION}</connectionExpression>

<subreportExpression class="java.lang.String">$P{SUBREPORT_FILE_NAME}</subreportExpression>

</subreport>

</band>

</detail>

<columnFooter>

<band height="30">

</band>

</columnFooter>

<pageFooter>

<band height="50">

</band>

</pageFooter>

<summary>

<band height="50">

</band>

</summary>

</jasperReport>

 

 

 

 

SubReport:

<?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="subReport"

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">

<parameter name="ADDRESSID" isForPrompting="true" class="java.lang.String"/>

<queryString><![CDATA[sELECT * FROM address WHERE id LIKE $P{ADDRESSID}]]></queryString>

<field name="id" class="java.lang.String"/>

<field name="street" class="java.lang.String"/>

<field name="city" class="java.lang.String"/>

<field name="state" class="java.lang.String"/>

<field name="country" class="java.lang.String"/>

<field name="zipcode" class="java.lang.String"/>

<background>

<band height="50">

</band>

</background>

<title>

<band height="50">

</band>

</title>

<pageHeader>

<band height="50">

</band>

</pageHeader>

<columnHeader>

<band height="30">

<staticText>

<reportElement

mode="Transparent"

x="6"

y="2"

width="78"

height="28"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<text>ID</text>

</staticText>

<staticText>

<reportElement

mode="Transparent"

x="93"

y="5"

width="110"

height="26"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<text>Street</text>

</staticText>

</band>

</columnHeader>

<detail>

<band height="50">

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="6"

y="9"

width="75"

height="33"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String">$F{id}</textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="93"

y="10"

width="116"

height="35"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String">$F{street}</textFieldExpression>

</textField>

</band>

</detail>

<columnFooter>

<band height="30">

</band>

</columnFooter>

<pageFooter>

<band height="50">

</band>

</pageFooter>

<summary>

<band height="50">

</band>

</summary>

</jasperReport>

 

When I compile in Ireport I always get the followint errors:

 

 

C:j2sdk1.4.1_01binjava.exe -Dorg.xml.sax.driver=org.apache.xerces.parsers.SAXParser IReportCompiler -c -pdf -jdriverorg.gjt.mm.mysql.Driver -juserroot -jpasswdncc1701d -jurljdbc:mysql://data/simon "C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.xml"

 

File: C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.xml

 

Compiling to file... C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.jasper

 

dori.jasper.engine.JRException: Errors were encountered when compiling report expressions class file:

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:99: ')' expected

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:99: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:99: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:99: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:99: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:99: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:99: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:99: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:99: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:187: ')' expected

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:187: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:187: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:187: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:187: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:187: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:187: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:187: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:187: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:275: ')' expected

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:275: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:275: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:275: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:275: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:275: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:275: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:275: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:275: illegal character: 92

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:99: cannot resolve symbol

 

symbol : variable C

 

location: class MasterReport

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:187: cannot resolve symbol

 

symbol : variable C

 

location: class MasterReport

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportsMasterReport.java:275: cannot resolve symbol

 

symbol : variable C

 

location: class MasterReport

 

value = (java.lang.String)(C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper);

 

^

 

30 errors

 

 

 

at dori.jasper.engine.design.JRCompiler.compileReport(JRCompiler.java:148)

 

at dori.jasper.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:135)

 

at dori.jasper.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:123)

 

at IReportCompiler.main(IReportCompiler.java:119)

 

 

 

Abnormal termination!

 

Could you help me to understand

 

Simon

.

 

 

 

 

By: Gregory A. Swarthout - gswarthout

RE: SubReport, need help to understand

2003-04-30 11:58

Is it possible you need quotes (") around this expression to treat it as a string?

 

<![CDATA[C:ProjectsThalasso_Pdgcodethalasso_pdgpr

opertiesxmlreportssubReport.jasper]]>

 

 

 

 

 

By: Giulio Toffoli - gt78

RE: SubReport, need help to understand

2003-04-30 12:01

Hi Simon,

 

this:

 

C:ProjectsThalasso_Pdgcodethalasso_pdgpropertiesxmlreportssubReport.jasper

 

is not a valid java code. It should be something like this:

 

"C:\Projects\Thalasso_Pdg\code\thalasso_pdg\properties\xml\reports\subReport.jasper"

 

Try now :-)

 

Giulio

 

 

 

 

By: Simon Chevrier - simonchevrier

RE: SubReport, need help to understand

2003-04-30 12:30

Thanks

 

It was obvious.

 

thanks a lot

 

Simon.

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...