Jump to content
Changes to the Jaspersoft community edition download ×

Conditions in Ireport


bigelo

Recommended Posts

Hello.

 

I am new with IReport so I hope that sb can help me.

 

How is it possible to use conditions in IReport.

 

Example:

 

I have two parameters. "Param1" is boolean and "Param2" is a String.

Now I only want that the value of Param2 is shown in the report only when Param1 ist true!!! (Sounds very simple ;) )

 

How can I do this (textfield expression)?

 

Thx a lot

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

bigelo,

 

Use the IF-ELSE ternary operators:

 

Code:
condition ? statement1 : statement 2

 

Explanation:

IF condition is true, statement1 is executed

ELSE statement2 is executed.

 

The statement given by kaunietiss is exactly the way you should interpret the example you gave.

Code:
[code]
Param1 ? Param2 : ""

 

The statement above has the same effect as...

 

Code:
[code](Param1 == TRUE) ? Param2 : ""

 

You normally would use this in Print when expression.

You could also use the statement in the middle of static text or in a text field.

This is very useful as you most likely will need it in many of the reports that you will be making.

 

 

Edwin

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...