#18 Upload reports and have them compile on the fly

closed-accepted
nobody
None
5
2005-10-31
2005-09-29
No

Good news, with the latest jasperreports release,
compiling reports on the fly became much easier using
the eclipse jdt compiler.

With this small patch, uploading a report that ends in
.xml or .jrxml will have it automatically be compiled.

Simply add to the start of ReportUploadAction.execute():

if ((command != null) &&
(command.equals(UPLOAD_COMMAND)))
{
MultiPartRequestWrapper multiWrapper =

(MultiPartRequestWrapper)ServletActionContext.getRequest();

File[] files =
multiWrapper.getFiles(UPLOAD_REPORT_FILE_PARM);
if (files.length > 0)
{
File reportUploadFile = files[0];
if (reportUploadFile != null)
{
String reportUploadFileName =
reportUploadFile.getAbsolutePath();
if
((reportUploadFileName.endsWith(".xml")) ||

(reportUploadFileName.endsWith(".jrxml")))
{
try
{

System.setProperty(JRProperties.COMPILER_CLASS,
JRJdtCompiler.class.getName());

JasperCompileManager.compileReportToFile(reportUploadFileName);
}
catch (Exception e)
{
log.error("Failed to
compile report: " + reportUploadFileName, e);
addActionError(e.getMessage());
}
}
}
}
}

The jdt-compiler.jar will also need to be added to the
classpath for the feature to be usable.

-Jasper

Discussion

  • Erik Swenson

    Erik Swenson - 2005-10-31

    Logged In: YES
    user_id=477376

    committed to CVS for 1.0-M2 release

     
  • Erik Swenson

    Erik Swenson - 2005-10-31
    • status: open --> closed-accepted
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks