Search code examples
jasper-reports

Would like to display "To be contined" for all pages in report and for last report "End of report" has to be displayed using iReport


I have designed an iReport where it should display all the records in the report. If a report has 2 pages for example then first page should display "To be continued" second page should display "End of the report" irrespective of number of pages you are working with.

I have placed a label at the footer of the report and changed the properties "print when expression" as

$V{PAGE_NUMBER}.equals($V{PAGE_COUNT}.toString()) ? "End of Report" : "Continue"

and displays error while executing the report

Error filling print... java.lang.String cannot be cast to java.lang.Boolean 
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean 

Solution

  • The property that you should fill is Text field expresion and change by:

    $V{PAGE_NUMBER}.equals($V{PAGE_COUNT}) ? "End of Report" : "Continue"
    

    because you are comparing Integers.

    Your text field in the xml should be:

    <textField>
        <reportElement x="xx" y="xx" width="xx" height="xx" uuid="xxxx"/>
        <textElement textAlignment="xxx" verticalAlignment="xxx">
            <font fontName="xx"/>
        </textElement>
        <textFieldExpression><![CDATA[$V{PAGE_NUMBER}.equals($V{PAGE_COUNT}) ? "End of Report" : "Continue"]]></textFieldExpression>
    </textField>