Displaying textField when not null

0

I have a text field with a yellow background and red font that I would like not to display when it is null.  By not displaying, I mean that I don't want the yellow background to display:

The XML for this field is attached:

sjl

 

 

Code:
<textField>
    <reportElement mode="Opaque" x="148" y="14" width="507" height="24" forecolor="#F00000" backcolor="#F8F800"/>
    <textElement textAlignment="Center">
     <font size="14"/>
    </textElement>
    <textFieldExpression class="java.lang.String"><![CDATA[$F{NODIFFMESS}]]></textFieldExpression>
 </textField>
 
</td></tr></tbody></table>
sjlevine's picture
Joined: Oct 15 2009 - 1:10pm
Last seen: 5 years 7 months ago

6 Answers:

0
I guess by saying you dont want to display your text field when its null, you mean there should be _NO_ textfield in cases of null.

Try this :

$F{NODIFFMESS} == null ? : $F{NODIFFMESS}
englbrechtful's picture
Joined: Sep 24 2009 - 5:20am
Last seen: 10 years 9 hours ago
0
You may also use the Print When Expression for your text field.
iancr01's picture
29
Joined: Aug 13 2007 - 7:04am
Last seen: 5 years 6 months ago
0
What would be the syntax of the Print When Expression when used for this purpose? It is not clear from the JasperReports Ultimate Guide.

sjl
sjlevine's picture
Joined: Oct 15 2009 - 1:10pm
Last seen: 5 years 7 months ago
3

Your 'Print when' expression should be like this:

new Boolean($F{NODIFFMESS} == null)

mdahlman's picture
9910
Joined: Mar 13 2007 - 2:43am
Last seen: 4 years 10 months ago
2

Requirement: Text message should be display in Table like "No Data found" if data is not returned. How can I achieve this? Thanks in Advance.

VimMang's picture
31
Joined: Feb 24 2016 - 3:39am
Last seen: 2 years 9 months ago
0

use coalesce or case like coalesce(field_name,'No Data found') or "case when field_name is null then 'No Data found' else field_name end"

rprachi2's picture
Joined: Jun 2 2016 - 10:47pm
Last seen: 1 week 6 days ago
Feedback
randomness