Jump to content
Changes to the Jaspersoft community edition download ×

iReport Variable initialization problem


2002 JI Open Discussion

Recommended Posts

By: SandeepRam - sandeepram

iReport Variable initialization problem

2005-05-06 07:06

hi,

 

I m using iReport 0.4.1 version. In the report design ' new Double(0) ' is used as Initial Value Expression in several text field variables . It works fine when these text fields have some value retrieved from the SQL query. But when these fields have null or no values it displays nothing (blank). I have ticked the 'Blank When Null' check box at the time of variable creation. I want to display ' 0 ' when there is no values in the variables. but it fails.

 

can any one help me.....

 

sanram

 

 

By: C-Box - c-box

RE: iReport Variable initialization problem

2005-05-08 01:40

Make an if-then-else-expression in your textfield instead of just using the field $F{MyDoubleField}

 

Something like:

 

($F{MyDoubleField}.equals(null))?new Double(0):$F{MyDoubleField})

 

so when your field $F{MyDoubleField} contains no value (null) you get a "0" printed instead a blank.

 

hth

C-Box

 

 

By: SandeepRam - sandeepram

RE: iReport Variable initialization problem

2005-05-08 10:14

hai C-Box,

 

i m already using the if-else expressing as u told.

I will give the variable expression that i m using , given below :

Eg: 1

 

(($F{transaction_type}.equals(new Integer(7))) ? new Double(new Long(java.lang.Math.round($F{amount}.doubleValue())).longValue())

:$V{w} )

 

In this $V{w} is intializes as--> new Double(0.00)

 

when $F{transaction_type} value not equal to 7

i want to display 0.00 , but nothing (blank )appears.

 

 

i will give u one more variable that i found problem.

 

Eg: 2

 

new Double($V{totuseradvance}.doubleValue()+

$V{totuserbill}.doubleValue()+

$V{totuserreg}.doubleValue()-

$V{totuserrefund}.doubleValue())

 

 

In this is even though these variables have some value nothing is displaying , only blank appears.

whats the reason.

 

i m now stuck with this issue.

 

can u find any solution to this?

 

with regards

 

sanram

 

 

 

 

By: C-Box - c-box

RE: iReport Variable initialization problem

2005-05-08 22:25

Well you should uncheck all attributes that prevent a field from displaying.

 

So for example the "BlankWhenNull" is not needed in your case.... because you are formatting your field in any case with your if-then-else-expressions.

 

I also don't know what your evaluation-times for the fields and variables are... perhaps that's the reason that your field is displayed at NOW and the variable is calculated at REPORT and at the time NOW the value is NULL and that's why nothing appears!?!?

 

Just some guess'

C-Box

 

 

By: Edward Mann - emann

Expression if else "and or"

2005-10-04 13:28

I have a report that is getting some data from a database. The fields that i have are money fields. However some have 0 as a value and some are blank/null and others actually have a value in them. When the field is blank/null or just have a 0 in them i don't want them to print. I have spent a few hours reading through the mailing lists and other sites, but i just cannot figure out how to write an expression that will report what i want.

 

i want something like this

 

if ($value != "") || ($value != "0") {

print the field

}

Any hints?

 

Thanks.

 

 

 

By: SandeepRam - sandeepram

RE: iReport Variable initialization problem

2005-05-13 12:00

hi C-Box,

 

The problem solved with less change.

I put the 'new Double(0.00)' in the Variable Expression of $V{w} , as i have done in the Initial Value Expression.

 

Then the report works !!.. i surprised why it happens. i think that when any variable's value , for eg: $V{totuserbill} is assigned to $V{w} , it doesnt gets '0' value but a null. So any calculation by using $V{totuserbill} after that , the entire result becomes null !!.

 

But it works fine with iReport-0.1 . Is it a bug in

iReport-0.4.1 ??

 

with regards

 

sanram

 

 

By: C-Box - c-box

RE: iReport Variable initialization problem

2005-05-15 00:23

It's no bug of iReport 0.4.1.... I guess you compare iReport 0.1 with a very old JasperReports-Lib in that iReport-Version.... so the 0.4.1 is using 0.6.4 or newer.... so it's probabely more a problem of your JasperReport version that is located in current iReport's lib-directory.

 

C-Box

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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