Jump to content
We've recently updated our Privacy Statement, available here ×

textField Expression on the font style based on the field value


jasperbox

Recommended Posts

I have the 2 text fields (field1 and field2) , and all I want is to put the logic that if field1 value is 'ADD', then the font of field2 value will be bold and italic. Now I hardcode the field2 value as bold and italic. I have no idea how to put this expression to put in this scenario: ( <condition> ? exp1 : exp2 ). Any ideas? Thanks so much!!!

   <textField isBlankWhenNull="true">
    <reportElement x="91" y="0" width="28" height="15"/>
    <box>
     <pen lineWidth="0.25"/>
     <topPen lineWidth="0.25"/>
     <leftPen lineWidth="0.25"/>
     <bottomPen lineWidth="0.25"/>
     <rightPen lineWidth="0.25"/>
    </box>
    <textElement/>
    <textFieldExpression class="java.lang.String"><![CDATA[$F{field1}]]></textFieldExpression>
   </textField>

   <textField isBlankWhenNull="true">
    <reportElement x="128" y="0" width="22" height="15"/>
    <box>
     <pen lineWidth="0.25"/>
     <topPen lineWidth="0.25"/>
     <leftPen lineWidth="0.25"/>
     <bottomPen lineWidth="0.25"/>
     <rightPen lineWidth="0.25"/>
    </box>
    <textElement textAlignment="Center">
     <font isBold="true" isItalic="true"/>
    </textElement>
    <textFieldExpression class="java.lang.Integer"><![CDATA[$F{field2}]]></textFieldExpression>
   </textField>

 

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...