tong123123 Posted November 14, 2018 Share Posted November 14, 2018 I try to use expression in a text field, and the language is set to groovy, what I input is a very simple if else statementif ($P{P_TFE_TYPE} == null || $P{P_TFE_TYPE} == ""){ "abc"}else{ "def"}.[/code]but this already throw exception asnet.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:calculator_RPT0010_1542190583832_137322: 472: unexpected token: if @ line 472, column 22.1 error. at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:109) at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:203) at net.sf.jasperreports.eclipse.builder.JasperReportCompiler.compileReport(JasperReportCompiler.java:286) at com.jaspersoft.studio.editor.preview.view.control.ReportController.compileJasperDesign(ReportController.java:481) at com.jaspersoft.studio.editor.preview.view.control.ReportController.access$8(ReportController.java:466) at com.jaspersoft.studio.editor.preview.view.control.ReportController$1.run(ReportController.java:369) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:calculator_RPT0010_1542190583832_137322: 472: unexpected token: if @ line 472, column 22.1 error at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310) at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:150) at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:120) at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:132) at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:360) at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:145) at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:111) at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:237) at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:167) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:931) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546) at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:102) ... 6 morewhat is the problem?I see a red underline under the opening {, and the tool tip ismissing EOF at '{'if I use expression like($P{P_TFE_TYPE} == null || $P{P_TFE_TYPE} == "")?"abc":"def"[/code]it can compile, everything run as expected.I know I can use ?: operator but don't want to as my if..else if condition is quite lengthy and complicated in reality, and feel hard to see if use tenary operator ?: 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