Jump to content

Try to use my own project classes in ireport


ktrinad

Recommended Posts

By: Simon Chevrier - simonchevrier

Try to use my own project classes in ireport

2003-05-30 05:27

Hi,

My new challenge, use my own project classes in IReport. IÂ’m using IReport version 0.1.0, I create a report with sub-report. Everything is working fine. I have currency value in my sub-report. In my project, I have a class that format the currency.

 

So, in IReport in the TextField Tool in the field TextField expression I wrote:

 

com.isiconseil.framework.utils.DisplayFormat.signedMoney($F{amount})

 

I make the process to test the result in IReport, everything is working, and my class formats the amount. (IÂ’m very happy).

 

Now I try it in Tomcat. When the report is compiling I get the following error:

 

package com.isiconseil.framework.utils does not exist

value = (java.lang.String)(com.isiconseil.framework.utils.DisplayFormat.signedMoney(

((java.lang.String)field_amount.getValue())));

 

My java files are in the java folder and the class files are in the classes folder.

EX:

 

..projectsrcjava my java file

..projectsrcWEB-INFclasses my class file

 

I modify the System.setProperty("jasper.reports.compile.temp", “”) with the 2 paths to known if the root path of my classes was wrong.

 

I donÂ’t known if someone has an idea of what I did wrong?

 

Thanks

 

Simon

 

 

 

 

 

By: Giulio Toffoli - gt78

RE: Try to use my own project classes in ireport

2003-05-30 08:41

Try one of this:

 

1. Try to copy your currency formatter class in tomcat/classes/com/isiconseil/framework/utils

 

2. Try to add explicitally your classes directory to the classpath adding a line in the script that start Tomcat

 

 

Giulio

 

 

 

 

By: Giulio Toffoli - gt78

RE: Try to use my own project classes in ireport

2003-05-30 08:42

P.S. We do the same thing to format other types of field and all run ok using Tomcat

 

 

 

 

By: Simon Chevrier - simonchevrier

RE: Try to use my own project classes in ireport

2003-06-03 05:51

Hi,

 

I can't modify the classpath because we have more than one application on the server. The production team wont want that I modify the classpath of the server. So I can’t use the System.setProperty("jasper.reports.compile.temp", “path”); configuration.

My question is about Tomcat. I donÂ’t known if I can post my question here?

With the call System.getProperty("user.dir"); The application will create the java file in the root folder of tomcat. It is the place where the java file is supposed to be creating?

When tomcat compile the java file, it is suppose to use all jar file in the lib folder and the class files in the classes folder? The application can find the class(HelloWorld.class) that I place in the classes folder of Tomcat, but when I call JasperCompileManager.compileReportToFile(reportNameFile); it never find the class.

If someone have a solution.

 

Thanks

 

Simon

 

 

 

 

 

By: Giulio Toffoli - gt78

RE: Try to use my own project classes in ireport

2003-06-03 06:24

 

Generally, you have not to compile the report every time you fill it...

 

However, try to put your classes in jasperreports jar. In this way, if you can compile (=you can call JasperCompileManager.compileReportToFile without problems), you'll find your classes too.

 

Giulio

 

 

 

 

 

By: Simon Chevrier - simonchevrier

RE: Try to use my own project classes in ireport

2003-06-03 11:19

If I understand I can create the java file, compile them with jbuilder one time. Place them in the root of my project (in the good package..) and call another method to generate the report.

 

If it is right, what is the way?

 

Simon

 

 

 

 

By: Giulio Toffoli - gt78

RE: Try to use my own project classes in ireport

2003-06-03 11:42

Yes, jasperreport work as a java program...follow me....

To write a java program you create a java source, compile it one time and then you executei trought the JVM any time you want.

In a similar way you create the report source (the XML), compile it (the result is not a java class but a jasper file, like myreport.jasper), then, trought the jasperreports API you can fill your report using few lines of code....

 

Example:

 

String reportFile = "path/to/your/reports/MyReport.jasper";

 

dori.jasper.engine.JasperPrint print=null;

dori.jasper.engine.JasperReport report = dori.jasper.engine.JasperManager.loadReport(cl.getResourceAsStream( reportFile ));

print = dori.jasper.engine.JasperFillManager.fillReport( report , map,this.getConnection());

 

The print object resulted can be exported in PDF, XLS,....

 

As you can see, we assume that exist an already compiled report called MyReport.jasper (compiled i.e. from iReport starting from MyReport.xml two weeks ago...)

 

Giulio

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...