Jump to content
Changes to the Jaspersoft community edition download ×

IR371 - Scriptlet Editor Problem


asikumari

Recommended Posts

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Asik Umar,

You're new to iReport 3.7, but I guess that you're familiar with iReport 3.0.x from a couple of years ago. That version had a scriptlet editor. There is no longer a scriptlet editor built-in to iReport.

The reasons are as follows:

  • The old scriptlet editor did not let you assign the class to a package (very bad form in Java)
  • The old scriptlet editor forced you to name the scriptlet identically to the report (not easily reusable between reports)
  • The old editor was just a simple text editor.
  • If you are writing a scriptlet (Java code) you are very likely to already have an IDE you prefer.
  • The old editor created scriptlets that extended it.businesslogic.ireport.IReportScriptlet (which itself extended net.sf.jasperreports.engine.JRAbstractScriptlet). This required deploying iReport.jar whenever you wanted to deploy a report using a scriptlet.
  • iReport only created a class file, so deploying it was difficult. The developer still needed to manually package this into a .jar file.

It wou ld have been possible to port this old editor into the new iReport. But it was decided that porting it as it was would be a bad idea. Improving it would be possible, but for now we determined that it would be more practical to always edit scriptlets outside of iReport by using either the IDE of your choice.

The steps you need to follow to use scriptlets today are these:

  • [optional] Find the .java file that you created in the iReport 3.0 scriptlet editor.
  • Create a new project in your IDE. Add jasperreports-x.y.z.jar as one of the libraries.
  • Create a new class that extends net.sf.jasperreports.engine.JRDefaultScriptlet
  • Code your scriptlet and build a jar file. (Enjoy the use of a package and of a reasonable name for the scriptlet and perhaps the presence of multiple scriptlets in the jar.)
  • In iReport add your new .jar file to the classpath. Tools -> Options -> iReport -> Classpath -> Add JAR. Be sure to set it as Reloadable so that any subsequent tweaks to your scriptlet are instantly picked up.
  • In your report in iReport find the Scriptlets node and set the appropriate Scriptlet Class for the default scriptlet called REPORT. (Enjoy the possibility of adding multiple scriptlets to the same report. This wasn't possible before.)
  • When deploying the report to JasperServer, remember to deploy your jar file. (Enjoy the fact that now you don't get stuck with iReport's generated class file that is not directly deployable. Enjoy not having to also deploy an iReport jar file.)

Regards,
Matt

Link to comment
Share on other sites

  • 5 years later...

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