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:
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:
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