Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
[BIRT 2.6.2] Define global JavaScript functions in library
rsenden
<p>I am developing some BIRT libraries in which I would like to define some global utility JavaScript functions. The usual way to implement this is to define the JavaScript functions in a .js-file, and reference this file in the library under Properties -> Resources -> JavaScript files.</p><p> </p><p>Unfortunately in my case, the reports and libraries need to be self-contained; they get deployed to an application server where I cannot install any new or updated JavaScript files (or any other resources for that matter). As such, the JavaScript utility functions need to be defined within the libraries themselves.</p><p> </p><p>The best solution I have come up with until now is to define an invisible Grid inside my library, with the onPrepare() event handler defining all utility functions. This works quite well, except for the fact that the utility functions are not available at design time within the library.</p><p> </p><p>For example, some of my data sets have computed columns that require access to the utility functions. This works OK when generating the report, but not when using the data set Preview function. As an example, see the attached rptdesign and rptlibrary. When previewing ScriptedDataSet in the library, the values contain 'dummy' because the utility functions are not available. The report is however generated with the correct value returned by the utility function ('abc').</p><p> </p><p>Is there any better way to implement this, such that the utility functions are also available at design time?</p><p> </p><p> </p><p> </p><p> </p><p> </p>
Find more posts tagged with
Comments
griniland
<p>What seems strange to me - if You can place report library file ot resource folder - are You sure, there is no way to place .js file there? </p><p>Try "Run report" instead of "Preview", m.b. this will help. </p>
rsenden
<blockquote class="ipsBlockquote" data-author="griniland" data-cid="121348" data-time="1381939029"><div><p>What seems strange to me - if You can place report library file ot resource folder - are You sure, there is no way to place .js file there? </p><p>Try "Run report" instead of "Preview", m.b. this will help. </p></div></blockquote><p> </p><p>In our product, BIRT reports and libraries are stored in a database. The product does contain a BIRT resources folder from which I can load files like images, css and js. However, the product is maintained by another team, and also the release cycles are different for product and reports/libraries. So, if we would take the external js-file approach, we would need to wait for a new product release before we can ship any report updates that require a newer version of the JavaScript library. Also, reports need to run on older releases, where the updated javascript library would not be available. Hence my question on the best way to implement fully self-contained reports/libraries.</p>