breback Posted June 25, 2013 Share Posted June 25, 2013 I am using iReport Designer 5.1.0. I have been reading up on scriptlets and implementing custom java code, but I cannot seem to make it work. The problem I want to solve is:I have a db connection and can access whatever I want just fine. However, there is a field that is a comma separated String which I want to do some operation on that is more complex than is supported by iReport, and then feed the results back into the report. More specifically, this field is a set of Strings (one String per entry in the db) that I want to feed in to a custom class. This class will do some operation over every String examined, and return a List to the report with the overall operation results.Writing the custom Java is an issue, but I need to know what links to what between the custom class and iReport. For example, where do I register the input value and the output value for this oepration.The steps I have taken so far are:1. Write the custom class extending JRDefaultScriptlet, export as a JAR2. Add the JAR to the classpath of iReport3. Create a scriptlet with the same name as the class4. Define a new variable with the same name as the custom class output; change calculation type to System???What other steps do I need to take to get the result I want? Is this even possible?Thanks Link to comment Share on other sites More sharing options...
Thomas Zimmer Posted June 30, 2013 Share Posted June 30, 2013 I did not understand finally what you are planning to do with the content in iReport (the string list), but apart from that from my point of view you already have done everything correctly; It is not mandatory to use a variable in the report to access the results of your java class. In all expressions in the report you may access all public methods of your scriptlet directly. Of course, you can write the result into that variable in the scriptlet, too, then use the variable in the report, but you don´t have to.A main point would be, at which time the result is calculated in the scriptlet class and and which time you access these values in the report execution process.If you want to print the list of strings from your scriptlet row-wise in your report, it would be a good idea to build a list datasource of them, then use this datasource with alist, table, crosstab, subreport, whatever.Hope this helps.Cheers, Thomashttp://www.thomaszimmer.net Link to comment Share on other sites More sharing options...
breback Posted July 1, 2013 Author Share Posted July 1, 2013 Yeah I figured it out (at least the implementation part). I'll try the datasource idea, thanks! 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