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)
adding common script to all HTML reports
pecks
Hi
I want to add some common script (JavaScript) to all of our reports. Rather than edit them all, it would be good to have them added in to the output report HTML. Do I need to edit the HTMLReportEmitter class to achieve this, or is there some kind of hook into the HTML generation that I could make use of? I have tried editing the jsps that ship with the runtime jar, but this doesn't seem to be the right approach as my script is called before the report generation has completed.
As further info, we're running Birt inside Jetty and then viewing the reports from a browser embedded in our app.
Find more posts tagged with
Comments
kclark
To share scripts across many reports you could add the JS or JAR to the resources folder. Then from the property editor you can add the property file/jar/js to make it available to that report.<br />
<br />
If you are trying to have the script run <em class='bbc'>after</em> it's been built and presented then you would need to call is from afterRender() <a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/810-eclipsecon-2009-advanced-birt-report-customization/#description'>This
devshare</a> is a good power point that will explain each method and when to use them.
pecks
Thanks for your answer.
That's not quite what I'm after - I should probably explain more.
Our clients already have a whole bunch of reports that they use.
We have a new requirement that, rather than reporting errors on the (HTML report) page, we should just redirect to an error page. This is easy if I can add script to the HTML that is produced by Birt, but I can't find a way to do this without editing the HTMLReportEmitter and building the jar myself.
So ideally, I want a way to add custom script to the report HTML without having to check out & build the whole Birt runtime jar. (As a corollary, what I don't want to do is to add custom script to 50+ different reports and push them out to our users).
kclark
Does the report need to be redirected automatically? One solution might be to use drill through where you would create an "Errors page" link that the user could click on directing them to the error report.
pecks
Yes, the requirement is that the redirection is done automatically. The reasoning is that we don't want the end-user to see the contents of the error.
kclark
I'll see if I can't find a way to redirect but here's a possible solution. You could loop through the data (I'm assuming it's in a table) checking for errors and making the error invisible to the end user or changing the output.
pecks
Thanks for your replies.
I have found a way to hide the errors, but again, this is a solution that would need to be added into every report. So I guess the crux of my problem is that I need a way to add some custom code (that is triggered after the report is generated) in such a way that I do not need to change all of the users existing reports.