nicoheber Posted May 4, 2011 Share Posted May 4, 2011 Hey guys,i have a problem with conditions in variables.I want to show the availabilities for some routers in a report. For this i created a master and a subreport. In the subreport i select the data for a router. When there are data, theres no problem. But when there are no data it only shows null for my calculations. I have two variables. The first is totaldowntime which sums all downtimes. The second calculates the availability with the formula: 100-$V{totaldowntime}/2592000*100. This works when there are data.But i want something like( $V{totaldowntime}=null ? 100 : 100-$V{totaldowntime}/2592000*100 ) from the user defined expression ( <condition> ? exp1 : exp2 ). But this dont work, i get the error:Errors compiling D:\Documents and Settings\heber\My Documents\ireports\Standortverfügbarkeit_subreport1.jasper! Compilation exceptions: com.jaspersoft.ireport.designer.compiler.ErrorsCollector@10093bc net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:calculator_Standortverfügbarkeit_subreport1_1304507380743_695713: 179: "(java.lang.Long) variable_Gesamtdowntime.getValue().toLong()" is a method call expression, but it should be a variable expression at line: 179 column: 103. File: calculator_Standortverfügbarkeit_subreport1_1304507380743_695713 @ line 179, column 103.1 error at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:101) at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:188) at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:215) at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:131) at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:515) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:calculator_Standortverfügbarkeit_subreport1_1304507380743_695713: 179: "(java.lang.Long) variable_Gesamtdowntime.getValue().toLong()" is a method call expression, but it should be a variable expression at line: 179 column: 103. File: calculator_Standortverfügbarkeit_subreport1_1304507380743_695713 @ line 179, column 103.1 error at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:296) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:829) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:511) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:487) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:464) at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:97) ... 6 more Can someone help me there? nico Link to comment Share on other sites More sharing options...
lpeel Posted May 5, 2011 Share Posted May 5, 2011 What happens if you change the language from Groovy to Java? I ran into a scenario where Groovy was the cause of a problem when I was evaluating against a null numeric field. Link to comment Share on other sites More sharing options...
nicoheber Posted May 6, 2011 Author Share Posted May 6, 2011 I changed the language from <Template Default> to Java and i dont see any changes in the report.So this cant be the problem.Maybe i did a mistake in the user defined expression, did i used it wrong? Link to comment Share on other sites More sharing options...
nicoheber Posted May 6, 2011 Author Share Posted May 6, 2011 i made a mistake changing the language. Now i really changed the language to Java and i get an other error. The left-hand side of an assignment muss be a variable: ($V{totaldowntime}=null ? 100 : 100-$V{totaldowntime}/2592000*100 ) this means for me that left of the : has to be variable like $V{availability}=100. But this dont work too.then i get the message: Syntax error on token "=", != expected : ($V{totaldowntime}=null ? $V{availability}=100 : $V{availability}=100-$V{totaldowntime}/2592000*100 )when i change this like in the message. i get again the error that The left-hand side of an assignment muss be a variable.So where is my real mistake now? editi changed $V{totaldowntime}=nullto $V{totaldowntime}==null so i dont get the message. but as result i get null too. so this dont really work :(Post Edited by nicoheber at 05/06/2011 09:17 Link to comment Share on other sites More sharing options...
jpauze Posted May 6, 2011 Share Posted May 6, 2011 Check this, chnag eit to $V{totalDowntime} == null, the single = is an assignment operation that is trying to set the variable to null versus compare it to null. Link to comment Share on other sites More sharing options...
nicoheber Posted May 9, 2011 Author Share Posted May 9, 2011 Thank you, but i already found this mistake, if u check the edit in my last post.I dont get any errors now. But the result is still null and not what i need.Any other ideas? 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