I already went through this same problem, I needed to paint each line of the report pair red, so I found following the solution:
<style name="style_fundo_vermelho" mode="Opaque">
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue() %2 == 0)]]></conditionExpression>
<style backcolor="#FF0000"/>
</conditionalStyle>
</style>
here in this section I create the Style that has a boolean condition:
(if the line counter number divided by 2 is = 0 then it is an even line and its background will be red)
new Boolean($V{REPORT_COUNT}.intValue() %2 == 0)
after creating this style with the name= style_botto_red i add it to the style attribute of textField:
<textField>
<reportElement style="style_fundo_vermelho" x="658" y="1" width="90" height="16" uuid="c118ccc6-4074-4f03-9bfa-cf6c3ae8a1b9">
</reportElement>
</textField>
So you can already solve your dynamic background color problem in text field, just adapt to style for your need.
Hello Julio, could you post one mvce with an example report, the call to generate it and the point at which you want to apply the style dynamically?
– Anthony Accioly