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)
Chart Interactivity Script Invocation
Patrick Branch
<p>I have created a report which contains a bar chart and have written a script which executes when any of the bars is clicked. When I render the HTML for the report using the Eclipse designer, parts of the JavaScript code have been replaced with the text 'null', making the script unusable. Below is an example</p>
<p> </p>
<p>A JavaScript function in the script:</p>
<div> </div>
<div>function transformToAssocArray( prmstr ) {</div>
<div> var params = {};</div>
<div> var prmarr = prmstr.split("&");</div>
<div> for ( var i = 0; i < prmarr.length; i++) {</div>
<div> var tmparr = prmarr
.split("=");</div>
<div> params[tmparr[0]] = tmparr[1];</div>
<div> }</div>
<div> return params;</div>
<div> }</div>
<div> </div>
<div>The JavaScript function after the report is run and rendered to HTML:</div>
<div><br><div> </div>
<div>function transformToAssocArray( prmstr ) {</div>
<div> var params = {};</div>
<div> var prmarr = prmstr.split("&");</div>
<div> for ( var i = 0; i < prmarr.length; i++) {</div>
<div> var tmparr = prmarr
.split("=");</div>
<div> nullparr[1];</div>
<div> }</div>
<div> return params;</div>
<div> }</div>
</div>
<div> </div>
<div>Notice how the first part of the entire fifth line has been replaced with "null".</div>
<div> </div>
<div>This appears to be a bug. If not, how do I prevent this from happening? Any help with this would be much appreciated.</div>
<div> </div>
<div>I attached a sample report using the Classic Cars, Inc. database which demonstrates the problem.</div>
Find more posts tagged with
Comments
Clement Wong
<p>Are you using open source BIRT, or commercial BIRT? What version?</p>
<p> </p>
<p>Do you have a sample .rptdesign using Classic Models that you can attach so that we can run to see the problem?</p>
Patrick Branch
<p>I'm using open source BIRT, version 4.5. I modified my original post to include an attached report demonstrating the problem.</p>
Clement Wong
<p>Thanks for updating and providing a sample to demonstrate the issue.</p>
<p> </p>
<p>It appears that "params" is a keyword for the parameters of the report and a substitution/lookup is being attempted.</p>
<p> </p>
<p>Try renaming the variable "params" to "parms" or "parameters".</p>
<p> </p>
<p> </p>
<p>This worked for me:</p>
<pre class="_prettyXprint">
var prmstr="something=thing1&somethingelse=thing2";
var parms = {};
var prmarr = prmstr.split("&");
var tmparr = prmarr[0].split("=");
parms[tmparr[0]] = tmparr[1];
debugger;
alert(parms[tmparr[0]]);</pre>
Patrick Branch
<p>Thank you so much; that worked. I was also previously unaware of the built-in substitution of the params variable with an object of report parameters, which proved to be useful. Is this documented anywhere?</p>