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

Assigning value not working


tanvirtonu

Recommended Posts

I want to assign a value of a parameter to a variable in Ireport.I have the following parameter and variable-
Parameter name- wasa
type-String
default value= null

variable name- wasa
Type-Integer
variable expression= blank (nothing written)
Initial value expression-( $P{wasa}== null ?
new Integer(0) : $V{wasa}.valueOf( $P{wasa} ) )

reset type= report

Now,I get the value of the parameter- wasa passed from the application but I get "null" from the variable- wasa
in Detail band.Amazingly,I get the value of the variable -wasa in Title band.What is the wrong in here?
One more thing,how can I run my report with blank data source from my application.If I dont write any SQL statement in Report Query, the report shows nothing.But I dont need anything from my database.

[file name=rent-6279094fd03d0d95af382a47460a342b.jrxml size=85376]
Post edited by: tanvirtonu, at: 2008/04/17 09:30

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

What happens if you set the Calculation Type of the variable to System?

 

From the application, use "new JREmptyDataSource()" instead of your connection object when you generate the report.

Post edited by: Pedja, at: 2008/04/17 09:40

Link to comment
Share on other sites

Pedja Brother you have always been soooo helpful to me.TONS of thanks to u brother.It alll worked after I did what you said.But brother can u pls tell me what is specialty of the calculation type setting to- system.What does it do?I saw it earlier also.
Link to comment
Share on other sites

Brother can you tell me what the problem is now.If I run the report from Ireport(with empty data source)giving some value to my parameters,everything shows well.But if I run the same report from my application it says-
couldnt creat the report,error evaluating the expression-: Source Text : ( $P{ElcA}== null ? new Integer(0) : $V{ElcA}.valueOf( $P{ElcA} ) )
I changed the calculation type- System and it worked well from Ireport but the problem is if I run from my application.Could u pls have a look at my report. [file name=rent-eeea4f3ae66f7429f90125d640fbb8c7.jrxml size=84927]

I noticed that if I run the report first time filling the MAP object,it works well.But later if I run the same report(by clearing the MAP first-map.clear() and then filling it with the SAME data from database) from another method in application, it shows the above error.Even I made sure that the newly entered values are assigned to the MAP object correctly.
Post edited by: tanvirtonu, at: 2008/04/18 21:06

Link to comment
Share on other sites

( $P{ElcA}== null ? new Integer(0) : $V{ElcA}.valueOf( $P{ElcA} ) )

 

Is this suppose to calculate the Integer value of $P{ElcA} if it is != null? Can you try

 

( $P{ElcA}== null ? new Integer(0) : Integer.valueOf( $P{ElcA} ) )

 

If that doesn't help, try to create new Map object instead of cleaning the one you have, I don't think it has anything to do with that but you can give it a try.

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