Jump to content
Changes to the Jaspersoft community edition download ×

Subreport + PageHeader


Rester

Recommended Posts

Hello,

 

I already looked in this forum and tried the solution ther without success :dry:

 

 

I createt a default Report with a Subreport for the Head, Detail and Footer

 

The First Page looks good But then JAsper doesn't repeat the Pageheader and PageFooter

 

 

her ist the Report

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="REPORT_DEFAULT"
columnCount="1"
printOrder="Vertical"
orientation="Landscape"
pageWidth="842"
pageHeight="595"
columnWidth="782"
columnSpacing="0"
leftMargin="20"
rightMargin="20"
topMargin="20"
bottomMargin="20"
whenNoDataType="BlankPage"
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="DS_FUSS" isForPrompting="false" class="net.sf.jasperreports.engine.JRDataSource"/>
<parameter name="DS_MAIN" isForPrompting="false" class="net.sf.jasperreports.engine.JRDataSource"/>
<parameter name="DS_KOPF" isForPrompting="false" class="net.sf.jasperreports.engine.JRDataSource"/>
<parameter name="SUBKOPF" isForPrompting="false" class="net.sf.jasperreports.engine.JasperReport"/>
<parameter name="SUBMAIN" isForPrompting="false" class="net.sf.jasperreports.engine.JasperReport"/>
<parameter name="SUBFUSS" isForPrompting="false" class="net.sf.jasperreports.engine.JasperReport"/>
<parameter name="MAP_KOPF" isForPrompting="false" class="java.util.Map"/>
<parameter name="MAP_FUSS" isForPrompting="false" class="java.util.Map"/>
<parameter name="MAP_MAIN" isForPrompting="false" class="java.util.Map"/>

<background>
<band height="0" isSplitAllowed="true" >
</band>
</background>
<title>
<band height="0" isSplitAllowed="true" >
</band>
</title>
<pageHeader>
<band height="100" isSplitAllowed="true" >
<subreport isUsingCache="false">
<reportElement
mode="Opaque"
x="0"
y="0"
width="802"
height="100"
key="KOPF"
/>
<parametersMapExpression><![CDATA[$P{MAP_KOPF}]]></parametersMapExpression>
<dataSourceExpression><![CDATA[$P{DS_KOPF}]]></dataSourceExpression>
<subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{SUBKOPF}]]></subreportExpression>
</subreport>
</band>
</pageHeader>
<columnHeader>
<band height="0" isSplitAllowed="true" >
</band>
</columnHeader>
<detail>
<band height="130" isSplitAllowed="true" >
<subreport isUsingCache="false">
<reportElement
x="0"
y="0"
width="802"
height="130"
key="MAIN"
/>
<parametersMapExpression><![CDATA[$P{MAP_MAIN}]]></parametersMapExpression>
<dataSourceExpression><![CDATA[$P{DS_MAIN}]]></dataSourceExpression>
<subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{SUBMAIN}]]></subreportExpression>
</subreport>
</band>
</detail>
<columnFooter>
<band height="0" isSplitAllowed="true" >
</band>
</columnFooter>
<pageFooter>
<band height="30" isSplitAllowed="true" >
<subreport isUsingCache="false">
<reportElement
mode="Opaque"
x="0"
y="0"
width="802"
height="30"
key="FUSS"
/>
<parametersMapExpression><![CDATA[$P{MAP_FUSS}]]></parametersMapExpression>
<dataSourceExpression><![CDATA[$P{DS_FUSS}]]></dataSourceExpression>
<subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{SUBFUSS}]]></subreportExpression>
</subreport>
</band>
</pageFooter>
<summary>
<band height="20" isSplitAllowed="true" >
<staticText>
<reportElement
x="22"
y="6"
width="146"
height="10"
key="staticText-1"/>
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
<textElement>
<font size="8"/>
</textElement>
<text><![CDATA[Hallo]]></text>
</staticText>
</band>
</summary>
</jasperReport>

 

 

 

Do someone has an clou what i'm doing wrong?

greetings

Rester

Post edited by: Rester, at: 2007/05/10 09:59

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hello,

 

Wenn ich put in the PAGEHEADER the code from the subreport ist works perfekt.

 

When I put the Subreport in the PAGEHEADER it just shows only in the first Page what i do wrong?

 

PLEASE HELP

Link to comment
Share on other sites

Hi,

 

You pass the data source of the subreports as a parameter.

I don't know what kind of data source it is, but I think what happens is that after the first pass, the data source gets consumed (the record pointer is at the last record) so it will look like an empty data source to the second occurrence of the subreport.

You need to devise a way to reposition the record pointer to the first record each time the subreport data source is used.

But that of course depends on the actual data source implementation.

 

I hope this helps.

Teodor

Link to comment
Share on other sites

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