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)
setting the resource path for the external .js files
newbie321
<p>Hi, </p>
<p> </p>
<p>I have some external .js files (containing functions) that I need to include with BIRT report at a run-time. I know that I can set the resources through GUI: Resources-> Javascript Files. (see attached screenshot)</p>
<p> </p>
<p>how do I set/include the resource path for the javascript external files programmatically from script in the .initialize() or .beforeFactory() event handlers? </p>
<p> </p>
<p>should be something like this, right ? </p>
<pre class="_prettyXprint">
reportContext.getReportRunnable()........</pre>
<p>But I am not certain on a full syntax..</p>
<p> </p>
<p>Thanks for help!!</p>
Find more posts tagged with
Comments
JFreeman
<p>I've done this externally using the Design Engine API to add the JS files while building the report.</p>
<p>Take a look at this post for details: <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/36804-how-do-i-use-javascritps-in-birt/?p=137333'>http://developer.actuate.com/community/forum/index.php?/topic/36804-how-do-i-use-javascritps-in-birt/?p=137333</a></p>
;
<p> </p>
<p>However, when I adapt this to be used inside the report design, it looks to be adding the script reference but the script is not accessible. It's looking like they may need to be included before the report is even initialized.</p>
<p>
Here is the adaption I've been trying in Initialize:</p>
<pre class="_prettyXprint _lang-js">
var is = org.eclipse.birt.report.model.api.StructureFactory.createIncludeScript();
is.setFileName("MyJSFile.js");
reportContext.getReportRunnable().designHandle.getDesignHandle().getPropertyHandle(reportContext.getDesignHandle().INCLUDE_SCRIPTS_PROP).addItem(is);
</pre>
newbie321
<p>Thanks, #JFreeman!</p>
<p> </p>
<p>I will try to run your code. </p>
<p> </p>
<p>I would be surprised if it is not possible. usually whatever is shown in birt's rcp GUI is accessible programmatically. </p>
<p> </p>
<p>Thanks again,</p>
JFreeman
<p>You're welcome.</p>
<p> </p>
<p>True, and It is possible to programmatically add a JS resource to a report using the Design Engine API, which is what the rcp application uses and what the other post I linked to shows. There is a chance though adding a JS resource is something that needs to have happened prior to runtime.</p>