Using Scriptlet in Jasper

Posted on by By admin, in Business Intelligence, Jaspersoft, Open Source Business Intelligence | 1

This blog will teach you how to use Scriptlet in jasper report.

Scriptlets :

Scriptlets act as an interface between Jasper reports and java

Using Scriptlet we can use user defined functions in jasper reports .

Scriptlet is a java class that extend one of the two following classes :

  • JRDefaultScriptlet
  • JRAbstractScriptlet

Using JRAbstractScriptlet , we should implement all the abstract metods.

Using JRDefaultScriptlet , we only need to implement the methods which we need for our project.

Since Scriptlet is a java class , so to add a sciptlet(user defined class) in jasper reports ,

  1. first step is to create a java class implementing user requirement.
  2. Then create its jar file
  3. In the iReport , go to Tools à Options àiReport à classpath ,

Add the jar files created by you in this location

  1. Then in the Scriptlet node of iReport , add the Scriptlet Name and fully qualified name of the jar that earlier you have created .

Capture

Here , in the Scriptlet Class , Reporting_Time is my class name

 

When we are done with creating a new scriptlet under Scriptlet node in iReport , We can see a new parameter created under parameter node ,

Named as {Name_Of_Scriptlet}_SCRIPTLET

In my case it is “Report_SCRIPTLET”

Using the above parameter we can call any methods declared inside the class.

 

Thanks,

Rupam Bhardwaj

logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

0 0 votes
Article Rating
Subscribe
Notify of
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

What jars did u use while writing the java code
which version jaspersoft u used