vickirk Posted December 16, 2008 Share Posted December 16, 2008 Hi,I'm wanting to set a parameter to a value but the expressionto set it is non trival and I really need to execute a fewlines of code to get the value. The value I'm trying to setis a date for yesterday to use in a query. I could change the sql to do this but I'd prefer to keep that DB neutral.iReport does not allow me to write a few lines of intermediatecode to get the value so I thought I'd try new java.util.Date() {{ Calendar cal = Calendar.getInstance(); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.HOUR, 0); cal.add(Calendar.DAY_OF_YEAR, -1); setTime(cal.getTime().getTime()); }} This compiles but causes an error (a NoClassDefFoundError)when I try to execute the report with JasperReport runningunder the bundled tomcat instance, so it looks like theanonymous class is not being found by the classloader.If I put this on say the RequestDate on the sample FrieghtReport I get the error: java.lang.Exception: 1 - ParamMany_1229428016587_36887 (wrong name: ParamMany_1229428016587_36887$1) at com.jaspersoft.jasperserver.irplugin.wsclient.WSClient.runReport(WSClient.java:394) at com.jaspersoft.jasperserver.irplugin.wsclient.WSClient.runReport(WSClient.java:311) at com.jaspersoft.jasperserver.irplugin.ReportRunner.run(ReportRunner.java:80) at java.lang.Thread.run(Unknown Source) Is there any other mechanism to set a variable to a non-trivial value in a jrxml file?Thanks, Vic Link to comment Share on other sites More sharing options...
lucianc Posted December 16, 2008 Share Posted December 16, 2008 Anonymous/inner classes in report expressions are not currently supported.What you can do is to put this code into a static method of a helper class, compile the class, put the compiled class/jar on the application&iReport classpaths, and call this method in your report expression (e.g. <defaultValueExpression>com.me.DateUtils.yesterday()</defaultValueExpression).Regards,Lucian Link to comment Share on other sites More sharing options...
vickirk Posted December 16, 2008 Author Share Posted December 16, 2008 Excellent, thanks for the quick reply :-) 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