Jump to content
Changes to the Jaspersoft community edition download ×

samhast
Go to solution Solved by marianol,

Recommended Posts

I trying to use the DateRange parameter. I followed the instructions from the iReport PDF. That's my code:

I have an error when I run the report:

Compilation exceptions: com.jaspersoft.ireport.designer.compiler.ErrorsCollector@91c832net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:calculator_all32op_1360591932552_649225: 131: unable to resolve class DateRangeBuilder  @ line 131, column 22.calculator_all32op_1360591932552_649225: 207: unable to resolve class DateRangeBuilder  @ line 207, column 22.calculator_all32op_1360591932552_649225: 283: unable to resolve class DateRangeBuilder  @ line 283, column 22.3 errors    at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:113)    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:201)    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:240)    at net.sf.jasperreports.engine.JasperCompileManager.compileToFile(JasperCompileManager.java:156)    at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:439)    at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:528)    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_all32op_1360591932552_649225: 131: unable to resolve class DateRangeBuilder  @ line 131, column 22.calculator_all32op_1360591932552_649225: 207: unable to resolve class DateRangeBuilder  @ line 207, column 22.calculator_all32op_1360591932552_649225: 283: unable to resolve class DateRangeBuilder  @ line 283, column 22.3 errors    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:109)    ... 7 more[/code]
Link to comment
Share on other sites

  • 1 month later...
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

Reposting aiklamha1 solution as an answer:

Just change the default expression from new DateRangeBuilder("DAY-1").toDateRange() to new net.sf.jasperreports.types.date.DateRangeBuilder("DAY-1").toDateRange()

Note:

Remember that when using this option the parameter class has to be set to DateRange (net.sf.jasperreports.types.date.DateRange). And this parameters are not date (java.util.dates) but ranges, so if you need to print (show) them in your report in a text field and use the patterns; you can use the getStart() or getEnd() methods.
for example:

 

new net.sf.jasperreports.types.date.DateRangeBuilder("MONTH").toDateRange()
$P{dateto}.getStart()

Check in the iReport Ultimate Guide Chapter 6.2.4 (http://community.jaspersoft.com/documentation) for a full example.

 

 

Link to comment
Share on other sites

  • 3 months later...

Now it works! thanks!

 

I have just one question, now my parameter have a default value expression:

new net.sf.jasperreports.types.date.DateRangeBuilder("MONTH").toDateRange()

Is it possible to replace "MONTH" with a parameter ? For example the user select in a list last month or last week and the value changes..

Is that possible?

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...