i want to use and/or in JasperReport expression i tried the following but it doesn't work:
($P{pId} == $F{id1}) or
($P{pId} == $F{id2} and F{return}=true)
? "good" : "bad"
but i am getting following exception:
Compilation exceptions: com.jaspersoft.ireport.designer.compiler.ErrorsCollector@1c9f37d net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions clas开发者_开发问答s file: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, calculator_report1_1318247835062_860381: 191: unexpected token: or @ line 191, column 144. 1 error at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:88) 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:509) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
any ideas why i am getting this exception and how to solve it.
and
and or
are not valid Java operators. JasperReports uses Java expressions. And since all Jasper parameters and fields are objects, I doubt you want to compare them with ==
. Use equals instead.
($P{pId}.equals($F{id1}) ||
($P{pId}.equals($F{id2}) && F{return}.booleanValue()))
? "good" : "bad"
精彩评论