Monday, April 27, 2020

[Java][Jasper][Resolved] jasper text field is blank when 0

[Java][Jasper][Resolved] jasper text field is blank when 0 Cannot found direct solution again but got a great idea from community of jaspersoft: It's by shrije :
"using an expression set zero to null value. and use "blank when null" option in text box."
For my case, suppose you defined a element named countA, with source data type java.lang.Integer. You have 2 things to do:
  1. Add isBlankWhenNull attrubute in your textField and set it as "true"
  2. Use a condition check in textFieldExpression element check if your field not 0, print null.
Example:
<textField isBlankWhenNull="true">
    <reportElement x="345" y="0" width="100" height="20" />
    <textElement textAlignment="Center" verticalAllignment="Middle">
        <font pdfFontname="MSung-light" pdfEncoding="UniCNS-UCS2-H" isPadfEmbedded="true" />
    </textElement>
    <textFieldExpression class="java.lang.Integer">
        $F{countA}.intValue()!=0?$F{countA}:null
    </textFieldExpression>
</textField>

No comments :

Post a Comment