saman0suke Posted January 8, 2011 Share Posted January 8, 2011 Hello, I'm trying to make a comparison here, so if the doc is equal to "1" it will print the result in a color, and if it's the other one, in a different one, but I'm getting this error:The left-hand side of the assignment must be a variableAnd here's the code:(new BigDecimal($F{document}).compareTo(new BigDecimal(1))=new BigDecimal(1)? "<style forecolor='#006633'>" + $F{total} + "</style>": (new BigDecimal($F{document}).compareTo(new BigDecimal(2))=new BigDecimal(2)? "<style forecolor='#ff0000'>" + $F{total} + "</style>": $F{total} ))Could you point me in the right direction? thanks! EDIT: I just found out that one of the problems lies here:"<style forecolor='#006633'>" + $F{total} + "</style>"ireport says that there's some incompatibility because I'm declaring "strings" and comparing BigDecimal, I managed to make it work, but without those tags, is there any way to solve it? thanks! Post Edited by saman0suke at 01/08/2011 17:53 Link to comment Share on other sites More sharing options...
teodord Posted January 10, 2011 Share Posted January 10, 2011 Hi, What is the type of your report fields? Can you attach here the entier JRXML? Thanks,Teodor Link to comment Share on other sites More sharing options...
saman0suke Posted January 11, 2011 Author Share Posted January 11, 2011 Well, I don't have it with me right now but let me give you that information: document is String, so that's why I convert it to BigDecimaltotal is BigDecimal. I checked again and the problem is the style tags, because it's giving me all the time the: "Cannot cast from string to bigDecimal" like it's recognizing the tags as part of the value that is going to be entered into the Field. By the way the target Field is BigDecimal, because the $total is BigDecimal on the select, thanks! Link to comment Share on other sites More sharing options...
madhuripatil Posted January 12, 2011 Share Posted January 12, 2011 If you are using iReport, I would suggest compile the report. It will give you compile time error in 'Report Problem Window' . You can double click on that error and find out where exactly is the type mismatch. I am not sure if above suggestion will work in your case. But it did work for me once. Link to comment Share on other sites More sharing options...
ceday Posted January 12, 2011 Share Posted January 12, 2011 probably this is whats wrong:new BigDecimal($F{document}).compareTo(new BigDecimal(1))=new BigDecimal(1)should benew BigDecimal($F{document}).compareTo(new BigDecimal(1))==1 ? ..there is another similar expression, you should change that one too.. 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