![](http://content.invisioncic.com/i328763/set_resources_3/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
samzilverberg
-
Posts
4 -
Joined
-
Last visited
Content Type
Forum
Downloads
Featured Visualizations
Knowledge Base
Documentation (PDF Downloads)
Blog
Documentation (Test Area)
Documentation
Dr. Jaspersoft Webinar Series
Security Advisories
Events
Profiles
Posts posted by samzilverberg
-
-
Hi all
Some background info:
My report gets its data from a mysql server using a simple sql query embedded in the jrxml.
One of the fields is a Boolean field (field class = Boolean).
In the mysql db the field is defined as bit(1) and null values are allowed (and used!).The problem:
In my report I want to display the value for this field and I want to use custom values for true/false/null.
So I created a textfield with expression class String and a simple expression:
($F{b}!=null):($F{b}.booleanValue()?"yes":"no"):"n/a"
I never see N/A printed although I triple checked and the value in the db is null.
I tried all kinds of work arounds using different expressions with no luck.
Finally I decided to neglect costum values.
I changed the textfield expression class to Boolean and use the most simple expression $F{b}
and still no null are displayed even though there are some null values.Blank when null is not checked for this textfield.
What can I do?
Why is jasper reports populating my Boolean field with false when it should be null?
cant display null Boolean values from db
in Products
Posted
I solved this by changing the field type to string and using textfield expression:
($F{b}!=null)?($F{b}.equals("1")?"Yes":"No"):"N/A"
The conversion of the db value to string preserves the null value as string, unlike the conversion to Boolean that converts it to Boolean.FALSE.
Post Edited by samzilverberg at 09/16/2010 11:46