spize Posted April 10, 2015 Posted April 10, 2015 Hi, I'm new to iReport and I've been trying to use "Print when expression" to change the value of a field in the database from 0 or 1 (I use MySQL, so no boolean) to Yes No. I've searched around but none of the solutions seems to be working for me. No matter what I try, I always get the same error at compile time : Error filling print... java.lang.String cannot be cast to java.lang.BooleanInteger.parseInt($F{myFieldName}) == 1 ? "Yes" : "No"I've tried various ways to do the comparison, including converting both operands to String or whatever. Fun thing, my comparison seems to "work", as in if I don't put in the if, my report compiles without problem but as soon as I add it the error shows up.I've also made sure my field type (Expression class) is set to java.lang.StringThanks.
Tom C Posted April 10, 2015 Posted April 10, 2015 "Print when expression" used in JR expects a boolean value return - it has nothing to do with the class type of the field you are trying to evaluate:Integer.parseInt($F{myFieldName}) == 1?true:falseYou can simply putInteger.parseInt($F{myFieldName}) == 1in the print when expression. If it's true, it will print out the element.
spize Posted April 10, 2015 Author Posted April 10, 2015 I see...And If I would like to control what appears in my Field based on a conditon, where should that be put if its not in Print when Expression ? EDIT: I found it a couple of minutes after, I needed to put the condition directly in the Expression field. Thanks for pointing me the right way !
bergomi91 Posted October 30, 2019 Posted October 30, 2019 EDIT: I found it a couple of minutes after, I needed to put the condition directly in the Expression field. Thanks for pointing me the right way ! what do u mean?
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