Scriptlet

  What is a Scriptlet?
A Script is a Java Class that extends one of the two following classes:


The sample extends the JRDefaultScriptlet. The difference between the two is with JRAbstractScriptlet a developer must implement all the abstract methods.
By extending JRDefaultScriptlet a developer is only required to implement that methods he/she needs for their project.
Once the Scriptlet has been referenced in the report, during the Filling stage of the Report Life Cycle, the JasperReports API will ensure to call the appropriate methods within the Scriptlet.
It is within these methods you will place your own logic to manipulate data in the report.

简言之,就是提供自定义操作(赋值,特殊运算处理等)!

例子:

例如某个变量AllCities需要特殊操作

1、在jrxml文件中,声明AllCities变量的时候,一定要将calculation设为"System"

如下所示:

<variable name="AllCities" class="java.lang.String" calculation="System"/>

2、在jrxml文件的标签jasperReport中,引用所使用的的scriptlets,如下所示:

scriptletClass="scriptlets.WebappScriptlet">

3、具体逻辑写到scriptlets的方法中

这些方法都是针对一些事件来写的!

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值