I created a set of utils to use inside my BIRT reports.
I put them (my-utils.jar) inside BIRT's lib directory:
BIRT_HOME\plugins\org.eclipse.birt.report.viewer_x.x.x.x\birt\scriptlib
They are working fine, but now I want to create a JS file, put it on the classpath to be able to use it functions.
// my-utils.js
GLOBAL_VARIABLE = {
formatSomething: funnction(value) {
// do my stuff with 'value' and return
}
};
I want to use it directly, without explicity load it inside a Dynamic Text or Script event, like this:
GLOBAL_VARIABLE.formatSomething('bla bla bla')
How can I do this?
You want to create an extension point. In Eclipse, create a new blank plugin-project, then add this extension point:
org.eclipse.birt.core.ScriptFunctionService
Create a folder just under the project root, name it for instance "jslib" and put your js files in this folder. Edit plugin.xml and add a JSLib tag, so that it should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="my.js.function"
name="My custom JS functions"
point="org.eclipse.birt.core.ScriptFunctionService">
</extension>
<JSLib
location="jslib">
</JSLib>
</plugin>
Export the plugin as a jar and deploy it in Eclipse and/or web applications and your js functions should be available. More informations about custom birt functions here