Portlight Posted January 17, 2011 Share Posted January 17, 2011 I am working on a report and need help with syntex. It has been awhile since I have worked in Java.Uisng the GUI in ireports this is the closest I have come to what I might use.$F{value}$F{value}.isEmpty()However when i try this....nothing changes. Desired result is:If the value field is not empty:Value (being the text label)1 (being the value in the database field)1If the value field is empty I do not want it to print anything - not even the text label Link to comment Share on other sites More sharing options...
fionn_colvin Posted January 20, 2011 Share Posted January 20, 2011 In the field put something like this($F{value} == "" ? " " : $F{value})That should then print the field if it is not empty or a blank space if it is. Link to comment Share on other sites More sharing options...
glenbdcs Posted January 21, 2011 Share Posted January 21, 2011 I have had to move back to v3.7.6 from v4 because I now believe ( <condition> ? exp1: exp2) does not work with nulls.I had been trying to make following work: ($F{PI_DISCOUNT} == null ? new java.lang.Double(0): $F{PI_DISCOUNT})where $F{PI_DISCOUNT} = holds a Sales Order Line Discount Rate as java.lang.Double.It does correctly display the $F{PI_DISCOUNT} value when != null but I never see 0.0 when a null exists. V3.7.6 and v3.7.4 does work correctly. Fortunately I had downloaded v3.7.6 earlier but not used because I cannot find where you can get this now.I am not a Java programmer so am prepared to accept I could be wrong but at least I now have it working. Link to comment Share on other sites More sharing options...
fionn_colvin Posted January 23, 2011 Share Posted January 23, 2011 What do you get displayed when a null exists? Or does the report fail to run with there are nulls? Link to comment Share on other sites More sharing options...
glenbdcs Posted January 24, 2011 Share Posted January 24, 2011 Using v4.0.0 ($F{PI_DISCOUNT} == null ? new java.lang.Double(0): $F{PI_DISCOUNT})If I have not selected (not ticked) the 'Blank When Null' property then I get 'null' in all the rows which have a null value.If I have selected (ticked) the 'Blank When Null' property then I get blank in all the rows which have a null value.----------------------------------Using v3.7.6 ($F{PI_DISCOUNT} == null ? new java.lang.Double(0): $F{PI_DISCOUNT})If I have not selected (not ticked) the 'Blank When Null' property then I get '0.0' in all the rows which have a null value and the Discount value such '10.0' if not a null value. (This is what I was expecting to get).If I have selected (ticked) the 'Blank When Null' property then I get '0.0' in all the rows which have a null value and the Discount value such '10.0' if not a null value. (This is what I was expecting to get). Hopes this helps - Glen. Link to comment Share on other sites More sharing options...
vecnar Posted February 3, 2011 Share Posted February 3, 2011 Writing to confirm the behaviour with double field value not replacing null in v4.0$F{Amount} == null ? new java.lang.Double(0): $F{Amount}In version 3.7.6 it works fine. Link to comment Share on other sites More sharing options...
mdahlman Posted February 3, 2011 Share Posted February 3, 2011 I'm pretty sure that this behavior is due to changes in Groovy. You could manually downgrade from Groovy 1.7.5 that ships with JR 4.0 to Groovy 1.5.5 to confirm this.You'll probably need to post the question to the JasperReports forum to get a more definitive answer. It's not really an iReport issue.Regards,Matt Link to comment Share on other sites More sharing options...
phantastes Posted February 4, 2011 Share Posted February 4, 2011 Hi,it does seem like an issue that could potentially throw off quite a few reports though, since the null check is not uncommon (at least not in my experience). Would this need to be filed as a bug? Since it seems to go against the backward compatibility that Jasper Reports has been quite good at maintaining.Magnus Link to comment Share on other sites More sharing options...
mdahlman Posted February 4, 2011 Share Posted February 4, 2011 It's definitely a valid bug report. (Again, for JR rather than iR)I don't know if/how it can be fixed... but that doesn't prevent logging it. In a worst-case scenario there may not be a way for us to work around Groovy's intentionally non-backwards-compatible change.When I heard about an issue similar to this (perhaps the same issue) I heard a follow-up that the JR team thought they found a way to avoid the problem. So either it's not avoided in all cases or else it's a bit different.Regards,Matt Link to comment Share on other sites More sharing options...
Teodor Danciu Posted February 14, 2011 Share Posted February 14, 2011 Hi, This is indeed related to the Groovy upgrade we made in JR. I was almost sure that any Groovy upgrade will bring problems as they pay little attention to backward compatibility.But that is besides the point... I'm not a Groovy expert but it seems they recently change the way null values are dealt with and we tried to find a way for reports to work the way they used to. Basically, if you add three NULL numbers with Groovy today, instead of getting a null pointer exception or something like that, you end up with the value "nullnullnull", which is not a number. So we had a class cast exception to deal with in JR.We made a modification in JR so that we keep trigger the old behavior, but this now prevents your logical expressions to work propetly, which is something I did not cover with my tests... Sorry.... Right now, I don't have any solution, so any feedback is welcomed. Thank you,Teodor Link to comment Share on other sites More sharing options...
lpeel Posted March 10, 2011 Share Posted March 10, 2011 I just ran into this issue, here is my post on the JasperReports forum http://jasperforge.org/plugins/espforum/view.php?group_id=112&forumid=102&topicid=85057I tried downgrading JR 4.0 to use groovy 1.5.5 and ran into trouble per above post. 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