rapthor Posted November 11, 2009 Share Posted November 11, 2009 Hello,I wonder how it is possible to work with a Java-Object in iReport that I can use for variable assignments later. For example, I am initializing a GregorianCalendar-Object by using its setTime() method:GregorianCalendar gc = new GregorianCalendar();gc.setTime(${DATE});I want to store this object instance somewhere in my report (like a code snippet that is executed once). I want to use the stored object instance to use the following expression as assignment for a new variable:gc.getTimeInMillis()How/where is it possible to store several lines of code that can be re-used in the report using iReport?Thanks in advance! Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted November 11, 2009 Share Posted November 11, 2009 You can create your own class, add it to the iReport classpath (Tools->Options->iReport->Classpath) and reference it in any expression you want in this way:com.my.package.MyClass.myStaticMethod( $F{what_I_need} )If you need to save the instance returned by some initialization method, I suggest you to use a variable of type System.This type of variables are never modified by JasperReports, so you can init them with a default expression, and their value does not change (if not explicitally changed by the user).Giulio Link to comment Share on other sites More sharing options...
rapthor Posted November 12, 2009 Author Share Posted November 12, 2009 Thank you for the advice! I have created a class that handles more complex stuff and that way extract it from iReports. Link to comment Share on other sites More sharing options...
balap6 Posted November 18, 2009 Share Posted November 18, 2009 Hi,i have crerated to two methods in the one java file. one method is used to set the values to object and another method is used to reterive the object. Object: it is Pojo Class with contains 10 variablesand the reterived obejct is stored in the Varaible type: System so in the detail band, i using that Varaible and calling the getter method of the class Type. some time the values are populating in to the reports and sometimes its not populating. can any one help to solve this issue Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted November 18, 2009 Share Posted November 18, 2009 Can you explain a bit better the problem and what you are doing? Thanks Giulio 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