gobenn71 Posted November 8, 2009 Share Posted November 8, 2009 Hi all, although i'm not new to JasperReports and iReport, i still don't understand the concept of the initial variable expression ! Can someone explain to me, why i always get an error like 'the inital value calss is not compatible with the variable's class', when i put the variable expression into the initial value expression ? my variable expression is generating a string and the variable has the type string. I simply don't get what the concept behind the initial value expression is, can someone explain it to me ? Link to comment Share on other sites More sharing options...
tdi120 Posted November 9, 2009 Share Posted November 9, 2009 Just remember that IReport considers the values you put as objects, and not as primitives. That is why you would have to put your String value into quotes like this:"mystring"and when using an integer, you would have to define the value as java expects it:new Integer(24)and when using an array list :new ArrayList(Arrays.asList(new Long[] {new Long(22), new Long(33)})); and so onThink that everything inside IReport is java. Objects, methods etc. Hope this helpsAlexandru ErsenieAll good things come to those who waitqants.wordpress.com Link to comment Share on other sites More sharing options...
gobenn71 Posted November 9, 2009 Author Share Posted November 9, 2009 But why does iReport then say 'the inital value class is not compatible with the variable's class', when i put "" or new String("") into the initial value expression of a variable which creates a String ? Is this possibly a bug in iReport 3.5.3 ? Post Edited by gobenn71 at 11/09/2009 12:28 Link to comment Share on other sites More sharing options...
tdi120 Posted November 9, 2009 Share Posted November 9, 2009 Because it is the value of the object you are using in the variable. that means, if you use a string, you'd have to put it like this: String.valueOf("mystring")and if your variable is of type integer:Integer.valueOf(23)AlexAll good things come to those who waitqants.wordpress.com Link to comment Share on other sites More sharing options...
gobenn71 Posted November 10, 2009 Author Share Posted November 10, 2009 I have still the same problem. I still don't get it. Is this a bug within iReport 3.5.3 ?I have a variable which should count the occurences of a group. The definition is as follows :variable class : java.lang.Integercalculation : countReset type : report variable expression : ($V{IndexCommodity_COUNT} != null && $V{IndexCommodity_COUNT}.intValue()==1) ? "" : null(this trick to count the occurences of a group was published in one of the iReport guide books...) initial value expression Integer.valueOf(1) I get the following error : The initial value class is not compatible with the variable's class WHY ?Post Edited by gobenn71 at 11/10/2009 07:46 Link to comment Share on other sites More sharing options...
buddhiama Posted January 28, 2010 Share Posted January 28, 2010 Here since your variable type is Integer you cannot return string value.*****variable expression : ($V{IndexCommodity_COUNT} != null && $V{IndexCommodity_COUNT}.intValue()==1) ? "" : null)just ignore the initial value expression. Leave it blank and run the report. If you still want the initial value of the variable as 1, Just set the variable expression as follows.variable expression : ($V{IndexCommodity_COUNT} != null && $V{IndexCommodity_COUNT}.intValue()==1) ? 0 : 1)Hope this helpsBuddhi Link to comment Share on other sites More sharing options...
achecchi Posted May 20, 2010 Share Posted May 20, 2010 I had the same problem. Its a bug.See: http://jasperforge.org/projects/ireport/tracker/view.php?id=4640 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