puperzenkarl Posted March 3, 2009 Share Posted March 3, 2009 I created a JasperReport template with iReport and checked the "Blank when null" checkbox for some text fields. When the associated field is null it prints a zero (Expression class is java.lang.Integer) and therefore is always visible. Why is that? Link to comment Share on other sites More sharing options...
puperzenkarl Posted March 3, 2009 Author Share Posted March 3, 2009 I think, the "Blank when null" option is not, what I am looking for. printWhenExpression should do it, but it doesn´t.I use Boolean.valueOf($F{total} != null) as printWhenExpression, but null fields still print a zero. Link to comment Share on other sites More sharing options...
C-Box Posted March 3, 2009 Share Posted March 3, 2009 In Java is null not the same as 0 (Zero) !!! So if you don't want to 0 values you should compare your field against 0 within the PrintWhenExpression Something like this: new Boolean($F{total}.intValue()>0) (if it's an integer field) hthC-Box Link to comment Share on other sites More sharing options...
puperzenkarl Posted March 3, 2009 Author Share Posted March 3, 2009 I know, but that is the problem. The field can be zero on purpose. In this case it would not be visible although it should be in the report. So I have to compare the value with null, but that seems to be impossible, because null fields will be initialized with zero when using java.lang.Integer. Link to comment Share on other sites More sharing options...
C-Box Posted March 3, 2009 Share Posted March 3, 2009 Hmm strange, within my reports (custom datasource) i get null for uninitialized Integerfields.Where are your field values come from? C-Box Link to comment Share on other sites More sharing options...
puperzenkarl Posted March 3, 2009 Author Share Posted March 3, 2009 I use the JRBeanArrayDataSource. The goal is, that uninitialized int values in the JavaBeans should not be visible in the report. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now