print when expression

hi all,

I have a report which includes the image and this image can be printed when the expression result is '0'

I would like to do that when the expression isn't '0', I want an answer instead of image, 'no info' for example

How could I do that?


new Boolean($F{BATTERY_LIFE_LOW}.equals('0'))</td></tr></tbody></table>
sedcal's picture
Joined: Sep 6 2010 - 4:44am
Last seen: 13 years 3 weeks ago

2 Answers:

You could place a static field or text field in the same position as your image with it's own print when expression. It would print out when your result is not "0".

svenn's picture
Joined: Mar 19 2007 - 5:57am
Last seen: 16 years 6 months ago

Yes, svenn is right. Whenever you want to display one of the two fields (e.g. either an image or some text), you can use the Print When Expression property in such a way that it will always be true for one of the two fields and false for the other.

I demonstrated exactly how to do this in one of the recipes of my JasperReports Cookbook. Please see recipe titled Applying styles to your data based on a logical or mathematical condition of chapter 9 Using Mathematical and Logical Expressions (available for free download, just click here). Especially see steps 13 and 15 of the recipe.

The Print When Expression property is very useful and can be used in many interesting and creative ways, together with the flexibility of mathematical and logical expressions that JasperReports offers. Chapter 9 demonstrates several ways of using the Print When Expression property.



Author, JasperReports 3.6 Development Cookbook

bsiddiqui's picture
Joined: Aug 16 2010 - 3:02am
Last seen: 13 years 1 month ago