Search code examples
jasper-reports

iReport variable expression returns null


Here's the simple code in XML view of print form:

<variable name="TITLE" class="java.lang.String">
     <variableExpression><![CDATA[$F{APP_NUMBER}.replaceAll( "app_", "" )]]></variableExpression>
</variable>

If I use this variable in form, it returns null (while using "$V{TITLE}"). But if I remove replaceAll method, it works and returns correct value. What is wrong with expression? Should I use something instead of "<variableExpression>"?


Solution

  • If you are printing this variable in Title band change its evaluation time to "Report"

    <title>
        <band height="79" splitType="Stretch">
            **<textField evaluationTime="Report">**
                <reportElement x="143" y="43" width="100" height="30" uuid="4fc0ce80-ced5-448e-bdd1-1571b3bc788f"/>
                <textFieldExpression><![CDATA[$V{TITLE}]]></textFieldExpression>
            </textField>
        </band>
    </title>