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 ,
- first step is to create a java class implementing user requirement.
- Then create its jar file
- In the iReport , go to Tools à Options àiReport à classpath ,
Add the jar files created by you in this location
- Then in the Scriptlet node of iReport , add the Scriptlet Name and fully qualified name of the jar that earlier you have created .
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
Best Open Source Business Intelligence Software Helical Insight is Here
What jars did u use while writing the java code
which version jaspersoft u used