Jump to content
We've recently updated our Privacy Statement, available here ×

how to change the null value


7rouz

Recommended Posts

  • Replies 12
  • Created
  • Last Reply

Top Posters In This Topic

== "null" doesn't work in I reports, however != "null" does, so I would do something like thing

Code:
new java.lang.String($F{fieldname} != "null" ? $F{fieldname} : "-"«»)

 

if the field u are using is not a string already then it needs to go like this

 

Code:
[code]new java.lang.String($F{fieldname}.toString() != "null" ? $F{fieldname}.toString() : "-"«»)
Link to comment
Share on other sites

thanks Case1182 for your reply.

my field is a string field.

but when i use you r solution i have this error message.

 

net.sf.jasperreports.engine.JRException:ÂErrorsÂwereÂencounteredÂwhenÂcompilingÂreportÂexpressionsÂclassÂfile: 1.ÂCannotÂcastÂfromÂStringÂtoÂBoolean ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂvalueÂ=Â(java.lang.Boolean)(newÂjava.lang.String(((java.lang.String)field_ENSEIGNANT_NOM_ENS.getValue())Â!=Â"null"Â?Â((java.lang.String)field_ENSEIGNANT_NOM_ENS.getValue())Â:Â"-"));/*$JR_EXPR_ID=15$*/ ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ<--------------------------------------------------------------------------------------------------------------------------------------------------------------------------> 2.ÂCannotÂcastÂfromÂStringÂtoÂBoolean ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂvalueÂ=Â(java.lang.Boolean)(newÂjava.lang.String(((java.lang.String)field_ENSEIGNANT_NOM_ENS.getOldValue())Â!=Â"null"Â?Â((java.lang.String)field_ENSEIGNANT_NOM_ENS.getOldValue())Â:Â"-"));/*$JR_EXPR_ID=15$*/ ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ<--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------> 3.ÂCannotÂcastÂfromÂStringÂtoÂBoolean ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂvalueÂ=Â(java.lang.Boolean)(newÂjava.lang.String(((java.lang.String)field_ENSEIGNANT_NOM_ENS.getValue())Â!=Â"null"Â?Â((java.lang.String)field_ENSEIGNANT_NOM_ENS.getValue())Â:Â"-"));/*$JR_EXPR_ID=15$*/ ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ<--------------------------------------------------------------------------------------------------------------------------------------------------------------------------> 3Âerrors ÂÂÂÂatÂnet.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:193) ÂÂÂÂatÂit.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:578) ÂÂÂÂatÂjava.lang.Thread.run(UnknownÂSource)

Link to comment
Share on other sites

megan ur code need to look like this:

Code:
new java.lang.String($F{C24} != "null" ? $F{C24} : "0"«»)

and double check to make sure uncheck the "blank when null" box

 

7rouz

I can tell it is boolean by ur error

Code:
[code]Cannot cast from String to Boolean value = (java.lang.Boolean)

you are trying to cast the string we are making into a Boolean field, either you are doing that or your iReports is bad, its the one telling you this not me.

Link to comment
Share on other sites

i wrote your code, checked n+1 times if the blank when null uncheked but i see the blank anyway.have no idea :S

 

moreover, I tried this on other string fields.No one field changed it`s value...and i found out that this field C24 in my example is not nullable.may be it means

if i enter to the code empty string "" that don`t help

so?any ideas?

Post edited by: megotronx, at: 2007/06/14 12:01

Link to comment
Share on other sites

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...