5

Can I put java code inside the .jrxml?

For example, I want to put an if() or a "new ..()"

Is it possible? How?

Thanks

Towfik Alrazihi
  • 536
  • 3
  • 8
  • 25

2 Answers2

5

You can't put any code, you can only put expressions. So, you can put:

  • new Something(someParameter)
  • somebool.booleanValue == true ? new Something() : new OtherThing();

but you can't use if, for, switch, declare methods or classes.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • If he'd modify the `toString` the object has, maybe he could accomplish some of the stuff he needs? – Geo May 12 '10 at 14:14
  • maybe.. I don't know what he needs :) – Bozho May 12 '10 at 14:16
  • +1 Do you have an example of how to use conditionals in jrxml? I have a relad question: http://stackoverflow.com/questions/2819812/how-can-i-use-a-conditional-textfield-in-jasperreports – Jonas May 12 '10 at 14:41
  • @Jonas, yup, answered there ;) – Bozho May 12 '10 at 17:22
0

use Scriptlet

Jasper Design Studio 6.2 Professional ,

Eclipse Mars.1 Release (4.5.1)

The full tutorial Scriptlet Example in Jaspersoft 6.x for begineers - Hello World Sample Example

Towfik Alrazihi
  • 536
  • 3
  • 8
  • 25