n d Jaspersoft Posted July 3, 2019 Share Posted July 3, 2019 Hi, What does the :, ? or null mean in an expression? Eg. ${f684_v} == null && ${f685_v} == null ? " " : (${f684_v} == null ? "-" : ${f684_v}) + " / " + (${f685_v} == null ? "-" : ${f685_v})What does the above mean?Any help or even link to a easy to understand website would be so appreciated.Thank you. Link to comment Share on other sites More sharing options...
C-Box Posted July 3, 2019 Share Posted July 3, 2019 I'll try do explain:Its a nested If Then Else expression.So first <null>... it means in java, not defined... just google for Java nullsecond, i guess (!?!) you wrote the syntax wrong...it should be $F{...} and not ${f..} ... so the identifier $F{any_fieldNameOfAQuery} means a field in a JasperReport.third the && means a logical AND operatorso your expression means: ( I level up the nested if-thens with fictive numbers)1. LEVELif Field "684_v" AND also Field "685_v" are bot null (remember: null = not defined/initialized) then print an emtpy space character " "OTHERWISE/ELSE 1. LEVEL 2. LEVEL if just field "684_v" is null, then print a minus character "-" OTHERWISE/ELSE 2. LEVEL concat the current field value "684_v" with a slash " / " String and 3. LEVEL if field "685_v" is null then again a minus char "-" OTHERWIESE/ELSE 3. LEVEL append the value of field "685_v"So if both fields are filled you will get something like "Hello / World" and if one of it's field is null you would either get "-/ World" or the other way "Hello / -" if both fields are null you just will get an empty space char " "now a bit more clear?!?! :-)hth + regardsC-Box Link to comment Share on other sites More sharing options...
n d Jaspersoft Posted July 3, 2019 Author Share Posted July 3, 2019 That is very helpful and very well explained!And yes, I had already deleted the F from the $F{...} ready for the new language I have to put them in. I will look how to write an IF Then Else epression in the new language. Thank you. What about this- ($F{f227_v} != null ? $F{f227_v} : "-") + " / " + ($F{f228_v} != null ? $F{f228_v} : "-")Is this similar or does the ! mean something? Link to comment Share on other sites More sharing options...
luked Posted July 3, 2019 Share Posted July 3, 2019 The != means (not equal) ? means (then): means (else) Link to comment Share on other sites More sharing options...
n d Jaspersoft Posted July 4, 2019 Author Share Posted July 4, 2019 Thank you very much luked This is a very helpful forum. 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