Search code examples
jasper-reports

How to hide while fields are empty in i-report


I wanted to hide text fields in jasper i-report when they are empty.

So I put this expression in those field's Print When Expression

$F{field_cashPaymentReceiptMode} != null && !"".equals($F{field_cashPaymentReceiptMode}) 

But then I got an error while compiling the report.

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
                value = ((java.lang.String)field_cashPaymentReceiptMode.getValue())!=null &&!"".equals(((java.lang.String)field_cashPaymentReceiptMode.getValue())); //$JR_EXPR_ID=33$
                                                                                             <-------------------------------------------------------------------->
1 errors

Please help me.


Solution

    1. Eliminate the Print When Expression altogether.
    2. Check Blank When NULL.

    Blank When Null

    1. Optionally, check Remove Line When Blank (only use this if you want the field to disappear completely, rather than retain its space on the page but have no content).

    Remove Line When Blank