• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Handling null values in Jasper report and jrxml

 
Ranch Hand
Posts: 186
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,

I have this following lines in my jrxml file:



Number of flags is a column name in database. This column is having null value in the table. I am executing the query in jrxml itself by passing a connection object in the fillReport method of Jasper.

A pdf report is generated properly but the column value is displayed as null,null... for 20 times, since there are 20 rows in the table.

How to chaeck for the null value and replace it by some other value, say, an "-" so that pdf report doesn't have the value displayed as null, if data is empty in the database table by changing the jrxml report template?

I am using Jasper version 2.0.3.
jrxml template created using iReport.

Kindly provide your help.
Regards,
Vijay
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vijay,

Try:
<textField isStretchWithOverflow="false" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self">

It should work.

Lalit
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just in case, if someone's looking for solution....

isBlankWhenNull="true" will only make it blank.

If you want to show a value like " - " or anything else... you should try this:-

<![CDATA[$F{Number of flags} != null ? $F{Number of flags} : "-"]]>
 
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chakri and welcome to Javaranch!
 
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!