Search code examples
jasper-reports

Jasper Reports: How to conditionally set the textbox style?


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>

Solution

  • 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.