Modified BIRT HTML Emitter, 增加自定义js代码

[url]http://www.birt-exchange.org/org/devshare/designing-birt-reports/1490-modified-birt-html-emitter/[/url]

下载:jar包[url]http://www.birt-exchange.org/config/devshare/visit.php?aid=1335[/url]

The purpose of this emitter is to allow a report developer to modify the HTML header that is generated in HTML based reports.

BIRT VERSION:-3.7
This devshare submission qualifies for Plug In 2 BIRT Contest
The purpose of this emitter is to allow a report developer to modify the HTML header that is generated in HTML based reports.
As a web based report developer, having access to the HEAD section of an HTML report allows the developer to include external Javascript libraries, such as Dojo, Google Maps API, or any of the Javascript libraries out there, in order to do more advanced and interactive reporting.

Once installed, the header can be modified by setting an ArrayList in the [url]reportContext.getAppContext()[/url] object. To make this easier, a helper function has been included using BIRTs User Function Extension point.
So, if a user wanted to add the Google Maps API, they would do something like the following in the beforeRender event of a report:

HeaderScriptHelper.AddHeaderTag(reportContext, " ");


The first parameter is the reportContext. This will always be the reportContext. This will never change.
The second parameter is the code to add to the HTML Head section. In this case, we are adding an inclusive Javascript statement for Googles Map API. Keep in mind, this is a client-side include, this will get executed at runtime on the client machine, which is why it is safe to add to the beforeRender event.

This is done in the order received, so you can have multi-line statements included as well. In the following example, we are defining a Javascript function that will update a Google Map Div Tag in the page when executed.

HeaderScriptHelper.AddHeaderTag(reportContext, " ");


只能在xml里面定义,在java里面会编译错误.
<method name="beforeRender"><![CDATA[HeaderScriptHelper.AddHeaderTag(reportContext, "<script type='text/javascript'> alert(1); </script>");]]></method>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值