Search code examples
jasper-reports

Null checking in ireport


I my web application I am using I-REPORT designer for designing report. For the data used in report,I have written a query that fetch two column values from different table.Here data type of column data is real.In ireport corresponding data type is Float.

Here,if one of the data have a value,other have a no value or empty.So I have to display a value that is not null or empty using text field,when the report is generated.So I have implemented condition in text field

( $F{permit_quantity}==null ?$F{fst_insp_qpqlml_quantity} : $F{permit_quantity} )

Here the fields $F{permit_quantity}, $F{fst_insp_qpqlml_quantity} corresponding to two column values returned by query.

But the above condition is not working when $F{permit_quantity} is empty or null.

I am using postgresql database


Solution

  • You can try to use .equals() Method if the condition itself is not working.

    $F{permit_quantity}.equals(null) ? $F{fst_insp_qpqlml_quantity} : $F{permit_quantity}

    There could be various other reasons why your code doesn´t work but I can´t tell from your snippet.