views:

223

answers:

1

Hi, Can I put java code inside the .jrxml?

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

Is it possible? How?

Thanks

+1  A: 

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
If he'd modify the `toString` the object has, maybe he could accomplish some of the stuff he needs?
Geo
maybe.. I don't know what he needs :)
Bozho
+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
@Jonas, yup, answered there ;)
Bozho