Home
Analytics
How to write resuable script for BIRT report
shahamar
I have a requirement where i want to write few script which can be used accross the BIRT report.
Is there any way where i can write script in Library or template so that it is available to all the reports.
I am modifiying the queryText on dataset open event. But this code is becoming redundant for different dataset and different report too. If i can write this code at one common place and i can call it, it will be very much managable.
Looking forward to a decent solution.
Thanks,
Amar
Find more posts tagged with
Comments
Virgil Dodson
Hi Amar,<br />
<br />
BIRT Scripting can happen within a report using Javascript or it can happen with an external Java class. There are a couple of external Java class event examples at <a class='bbc_url' href='
http://www.birt-exchange.com/modules/wfdownloads/singlefile.php?cid=2&lid=339'>http://www.birt-exchange.com/modules/wfdownloads/singlefile.php?cid=2&lid=339</a><br
/>
<br />
In your example, after selecting the Data Set, select the properties tab and then Event Adapter to point at your Java class.
shahamar
Hi vdodson,
Thanks for the reply.
Writing java class for Event Adapter will definetly work out.
But, only thing is if there are any changes in this code it has to go ful cycle of compile - - build - deploy.
Is there any way to write few Javascript function some where in Report/report template/ report library so that it can be made available to reports in the application. In that sense i just need to copy the updated report component in case of any changes.
it will be great to know if any thing such I can write.
Thanks Again,
Amar
Virgil Dodson
Hi Amar,
Yes, you can also store elements inside a library which will not require any compiling step, just deploy the new library. In this case, you create your scripted data set, and then store that data set and data source in a library. Multiple reports can use that data set from the library. In BIRT 2.3, you will have the additional capibility of storing an external JavaScript(.js) file for one more level of abstraction.