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

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

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

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 reportContext.getAppContext() 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>

你可能感兴趣的:(html)