Using JasperReports Scriptlet

別忘了compile 時要加入jar檔, 如:
F:\>javac Scriptlet.java  -classpath “C:\Program Files\jasperserver-pro-3.1\ireport\lib\jasperreports-3.1.2.jar"
並且把ireport內的classpath加入f:\

Rodrigo De Castro: Using JasperReports Scriptlet

Using JasperReports Scriptlet
Posted by Rodrigo de Castro at 6:15 AM
In a few steps:

* Create a class that extends the following class:
o net.sf.jasperreports.engine.JRDefaultScriptlet.
* Either:
o Add this class name (qualified name, actually) in the scriptletClass attribute of jasperReport element of your .jrxml file;
o Or, in case you are using iReport, declare this class in Project/Project Options menu, Scriptlet tab and “Use this scriptlet class…" option.
* After that, if you created a new method, call it using the following syntax:
o “$P{REPORT_SCRIPTLET}.methodName()".
+ In my case, I added to the group header the call to the method “priorityDescription()".

The scriptlet I created uses a field value to return a more complex description, what I am unable to do using only the variable declaration. It is also possible to override many of the methods that JRDefaultScriptlet provides, such as:

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *

What is 7 + 2 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)