tanvirtonu Posted April 16, 2008 Share Posted April 16, 2008 I have the following things in my report Parameter- demoType-Stringdefault value=null Variable-demo1Type-Integervariable expression-( $P{Demo}.equals( null) ? new Integer(0) : $V{demo1}.valueOf( $P{Demo} ) ) Even if I set null to parameter demo,the value of variable demo1 is shown - null instead of 0. The problem is solved when I put the expression in Initial value expression of variable demo1.BUT CAN ANYBODY TELL ME WHY it is working now.And one more thing if i write $P{Demo}.equals( null),this is not recognized,but $P{Demo}== null is recognized, what is the difference?Post edited by: tanvirtonu, at: 2008/04/16 08:33 Link to comment Share on other sites More sharing options...
Pedja Posted April 16, 2008 Share Posted April 16, 2008 If you want to test if a parameter is null, use $P{Demo}==null, because you can't call a method on a null object. Link to comment Share on other sites More sharing options...
tanvirtonu Posted April 16, 2008 Author Share Posted April 16, 2008 Thnx brother.Can u tell me what is the difference between initial value expression and variable expression of a variable.And why it is working in my case above? Link to comment Share on other sites More sharing options...
Pedja Posted April 16, 2008 Share Posted April 16, 2008 Initial value of a variable is the value it has when it initializes, if you have a variable that is Integer and you don't specify initial value it will be null, you can set it to new Integer(0). Variable expression is what the variable "listens to", if you set it to $F{field} and the Calculation Type is Sum, then it will sum the values of $F{field}. Experiment with it, it all depends on the use case. 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