jo_bonanno Posted October 4, 2006 Share Posted October 4, 2006 How to code in Textfield expression if I wanted to make a simple label change base on the query result as per the below... If $F{abc} = J display "Job"else if $F{abc} = E display "event"else display "Others" Link to comment Share on other sites More sharing options...
lucianc Posted October 4, 2006 Share Posted October 4, 2006 You can eitheruse the "? :" Java operator (the code assumes that $F{abc} is a java.lang.Character, you can adapt the code otherwise):Code:Write a decoding method in some accessible class and use it:Code:DecodeHelper.decodeABC($F{abc})[/ul] HTH,Lucian Link to comment Share on other sites More sharing options...
jo_bonanno Posted October 11, 2006 Author Share Posted October 11, 2006 I have change it to $F{acType}.charValue == "J"?"JOB" : ($F{acType}.charValue() == "E"?"Even") but what I rcvd were error messages... Would be great if u could check for me. thanks. Link to comment Share on other sites More sharing options...
lucianc Posted October 11, 2006 Share Posted October 11, 2006 First of all, is acType a java.lang.Character field or not? The code I posted contains a syntax error (should start with $F{abc}.charValue() == ..), it was only meant to give you an idea of what a decoding expression would look like. You have further syntax errors in your expression: character literals use single quotes ('J'), and the "? :" operator is incomplete. JR expressions are Java expressions (if you use a Java-based report compiler) with param/field/var placeholders, so familiarity with Java expression syntax is a prerequisite for writing complex expressions. HTH,LucianPost edited by: lucianc, at: 2006/10/11 09:22 Link to comment Share on other sites More sharing options...
jo_bonanno Posted October 11, 2006 Author Share Posted October 11, 2006 Ok now Ive got it... the amended syntax is as per below: $F{acType}.equals("J") ? "JOB" : $F{acType}.equals("E") ? "Even" : $F{acType} Thanks bro Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now