I need to enable the reports with 3 types of the page headers: "first page header", "middle pages header" and "last page header". All of these headers can have different number of report elements and on different positions. Same goes for the footers.
NOTE: The report must support the report elements like jr:table or jr:list in its Detail
band. These element must be supplied with the data via xml datasources.
I was able to simulate first page header by using Title
band, but I'm having problems enabling "middle pages header" and "last page header". This is what I'm trying to do:
<pageHeader>
<band height="100" splitType="Stretch">
<frame>
<reportElement x="0" y="0" height="100" width="555" uuid="f788c74b-6853-4bc7-8ed7-5e3d538287c9" isRemoveLineWhenBlank="true">
<printWhenExpression>
<![CDATA[new Boolean($V{PAGE_NUMBER} == $V{PAGE_COUNT})]]>
</printWhenExpression>
</reportElement>
<staticText>
<reportElement x="1" y="1" width="100" height="20" uuid="9777208b-5323-4045-aa49-a849d5c00c89"/>
<text><![CDATA[LAST PAGE HEADER TEXT 1]]></text>
</staticText>
<staticText>
<reportElement x="50" y="10" width="200" height="50" uuid="15313676-09e6-4d17-ac75-2df99f61bfee"/>
<text><![CDATA[LAST PAGE HEADER TEXT 2]]></text>
</staticText>
</frame>
<frame>
<reportElement x="0" y="0" height="100" width="555" uuid="65577abd-8717-477a-f27e-c70e9eba46af" isRemoveLineWhenBlank="true">
<printWhenExpression>
<![CDATA[new Boolean($V{PAGE_NUMBER} != 1) && new Boolean($V{PAGE_NUMBER} != $V{PAGE_COUNT})]]>
</printWhenExpression>
</reportElement>
<staticText>
<reportElement x="70" y="0" width="300" height="100" uuid="0a866eb3-85cf-4376-d6a4-21b534d36df0"/>
<text><![CDATA[MIDDLE PAGE HEADER TEXT 1]]></text>
</staticText>
</frame>
</band>
</pageHeader>
I'm using frame
blocks along with printWhenExpression
. Depending on the printWhenExpression
condition, only one of two frame
blocks should be printed (with all of its content). First frame block should render "last page header", and second one should render "middle pages header".
The problem lies within the first frame
("last page header") printWhenExpression
:
<printWhenExpression>
<![CDATA[new Boolean($V{PAGE_NUMBER} == $V{PAGE_COUNT})]]>
</printWhenExpression>
In this case, $V{PAGE_NUMBER}
always equals $V{PAGE_COUNT}
because of the evaluation time.
Is there any way to check if the current page is the last page? Also, is there any other way to enable "middle pages" and "last page" headers?
NOTE: I was able to implement similar logic for the footers by using the frames
and Last Page Footer
band!
currentPage
variable returnsnull
on all pages except the first one.