ag201 Posted January 17, 2007 Share Posted January 17, 2007 hi guys, i have this boolean value field, which i want to display as Yes or No, instead of true or false respectively. Can somebody tell me how i can do this. thanks. Link to comment Share on other sites More sharing options...
wegnerk Posted January 17, 2007 Share Posted January 17, 2007 you could use the PrintWhenExpression of that textfield. I don't know, how it looks like, so it is a bit speculation... so, try it like $F{DBField}==true : "yes" ? "no" or something similar. For that, the textfield has to be a String - field. hope this helps a bit Link to comment Share on other sites More sharing options...
jmurray Posted January 17, 2007 Share Posted January 17, 2007 Very close. The expression would be something more like $F{DBField}.booleanValue()==true ? "yes" : "no" Link to comment Share on other sites More sharing options...
ag201 Posted January 18, 2007 Author Share Posted January 18, 2007 doesnt work for me. i am getting a bunch of errors. net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 1. The method booleanValue() is undefined for the type String value = (java.lang.Boolean)(((java.lang.String)field_can_centrifuge.getValue()).booleanValue()==true ? "yes" : "no"); <----------> <----------------------------------------------------->any ideas? Link to comment Share on other sites More sharing options...
ag201 Posted January 18, 2007 Author Share Posted January 18, 2007 guys let me back up ok. my sql query returns a field which is a boolean in the DB. so now i create a field in my report with type string and right click on it select properties, use this as the print expression, $F{is_loggedin}.booleanValue() == true ? "Yes" : "No" for it. now when i go under view->fields, under that i have is_loggedin as string too. now sometimes i am getting the error saying that booleanValue is not the right function for a string and sometimes i am getting cannot cast from string to boolean. i have done this in the past, but now am totally stuck. any help guys. Link to comment Share on other sites More sharing options...
wegnerk Posted January 19, 2007 Share Posted January 19, 2007 if your field is of type String, you have to take the .equals() function, so Code:$F{loggedIn}.equals("true"«») and so on. Or, if you are not sure, if its lowCase or not, you can take equalsIgnoreCase("")... Hope this helps a bit... 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