Add "Continued on next page..." text in the footer of each page except the last page in Jasper report. So basically i want to let the user know that there's more to view on the the next page of the report. I am aware of page x of y thing, which also let us know if there are more pages to see, but i want to make it more user friendly.
Created a custom variable as below:
<variable name="pNumber" class="java.lang.Integer" resetType="Page">
<variableExpression><![CDATA[1]]></variableExpression>
<initialValueExpression><![CDATA[$V{PAGE_NUMBER} + 1]]></initialValueExpression>
</variable>
Created the TextField in the footer as below:
<textField evaluationTime="Auto">
<reportElement mode="Opaque" x="0" y="0" width="555" height="15" backcolor="#D1CBCB" uuid="dd084b9e-66ab-494a-ad7d-0860be1796fb">
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Continued on next page..." + $V{pNumber} +"!="+ $V{PAGE_NUMBER} + " : "+ new Boolean(($V{pNumber}.equals($V{PAGE_NUMBER})) == false)]]></textFieldExpression>
</textField>
Now, when i run the report which has total 3 pages, the TextField content shows the below text in each page as mentioned:
First Page: Continued on next page...1!=3 : true
Second Page: Continued on next page...2!=3 : true
Third Page: Continued on next page...3!=3 : false
This expression works perfectly fine in the Text Field expression. Now, i want to use the same condition in Print When Expression of the TextField which will allow me to show the "Continue...text" if it returns true,or else nothing if false.
<printWhenExpression><![CDATA[new Boolean(($V{pNumber}.equals($V{PAGE_NUMBER})) == false)]]></printWhenExpression>
I searched a lot on this issue, but didn't find any straight forward solution. Btw I am using TIBCO Jaspersoft® Studio 6.1.1 - Visual Designer - community edition for JasperReports
The problem of using it in Print When Expression is its evaluationTime
that you can not change so you need hacks like Compare current page number with last page number
The true solution to this problem however is to use the <lastPageFooter>
band, it was added to be able to have different content in last page footer, hence no need for expressions with hacks, just leave it without the textField
.