Jump to content
Changes to the Jaspersoft community edition download ×

print field if value =


Portlight

Recommended Posts

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)

1

If 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

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

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

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

  • 2 weeks later...

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

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

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

  • 2 weeks later...

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

  • 4 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...