agna.desai Posted July 8, 2016 Share Posted July 8, 2016 I am trying to use lamda expression inside .jrxml file to get values for my field. I imported appropriate classes but it is giving me error that "p cannot be resolved to a variable". How to use a lamda expression inside jasper. Please help. I am using jasperreports 6.3.0. <jr:listContents height="20" width="400"> <textFieldExpression> <![CDATA[stringUtils.join(((Collection<Property>)((Object2)$F{field1}.getPropertyValue("property1")).getPropertyValue("property2")).stream().map(p->((Object1)p.getValue()).getName()).collect(toList()),',');]]></textFieldExpression> </textField> </jr:listContents> </jr:list> Exception net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 1. p cannot be resolved to a variable Link to comment Share on other sites More sharing options...
hozawa Posted July 11, 2016 Share Posted July 11, 2016 I don't think lamba expression are supported inside jrxml. You'll have to use Scriplets. Link to comment Share on other sites More sharing options...
Solution lucianc Posted July 11, 2016 Solution Share Posted July 11, 2016 Lambda expressions in reports work with a recent JDT compiler jar (e.g. 4.5.1 from Maven http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.eclipse.jdt.core.compiler%22%20AND%20a%3A%22ecj%22) and with the following properties in jasperreports.properties:org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8org.eclipse.jdt.core.compiler.compliance=1.8org.eclipse.jdt.core.compiler.source=1.8 It also works with the 1.8 javac compiler used for reports, but using the JDT compiler is the recommended setup. Regards,Lucian 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