Reputation: 5940
Is it possible in Jasper Reports to conditionally set a textbox style? If yes, how?
Please note that I'm aware of conditional styles, but I do not need a style which varies on a condition, but set the proper style using a different condition for each textbox (of course I could create a conditional style for each textbox, but that would be a real PITA...).
I'm using Jasper Reports 3.7.6 and the Jasper Studio Eclipse plugin.
Thanks
Use case example pseudocode:
bean1 { f1 f2 } bean2 { cond1 cond2 } <textbox1 style="(bean2.cond1 ? style1 : style2)"> bean1.f1 </textbox1> <textbox2 style="(bean2.cond2 ? style1 : style2)"> bean1.f2 </textbox2>
Upvotes: 1
Views: 1148
Reputation: 5940
Answering myself: it turns out that it is not possible to set conditional style the way I needed. I ended up with duplicating each text fields (a copy for each style), then setting the visibility upon the condition. Boring and time consuming, but it works.
Upvotes: 0
Reputation: 1341
Unfortunately you can't define a generic style. See page 135 of the iReport Ultimate Guide: http://community.jaspersoft.com/documentation/ireport-ultimate-guide:
Please note that the conditions cannot be generic, for instance, you cannot set a condition like “if the number is positive” or “if the string is null .” You must be very specific, specifying, for example, that a particular value (field, parameter, variable or any expression involving them) must be positive
or null, and so on.
Upvotes: 1