Sunday, March 11, 2007

BIRT Milestone 5 New and Notable

The New and Notable for milestone 5 is now available. This milestone contains many improvements to the Charting Package and the example Web Viewer. Additionally PostScript output is now supported.


As part of compiling the new features, I designed a report that would make use of the script tag within a Text element. This report executes every 10 seconds and alters what is rendered based on some check boxes within the report.



Each check box is built similar to the following code implemented in a Text element.


<form name="cbform">
<input type="checkbox" name="mycheckbox" <VALUE-OF>if( params["hideOfficeCodeLabel"].value){
"checked";
}else{
"";
}</VALUE-OF>>Hide Office Code</input>
</form>


The check box is linked to a report parameter, which in turn is tied to the visibility property of a column in the report.



The report contains a script function called reloadPage, which builds a new
URL based on the check boxes and reruns the report every ten seconds. This function was created in the first Text element of the report.

<form name="input" onSubmit="return reloadPage();">

<script type="text/javascript">


function reloadPage() {
var temp = new String(location.href);
var targetURL = new String();
var altchart = "1";

if( temp.indexOf("&altchart=1") != -1){
altchart = "2";
}else{
altchart = "1";
}
if(temp.indexOf("__overwrite=") != -1 ){
targetURL = temp.substring(0, temp.indexOf("&__overwrite") -1);
}else{
targetURL = temp;
}

targetURL += "&__overwrite=true";
targetURL += "&hideOfficeCodeLabel=" + document.cbform.mycheckbox.checked;
targetURL += "&hideCityLabel=" + document.cbform2.mycheckbox.checked;
targetURL += "&hideStateLabel=" + document.cbform3.mycheckbox.checked;
targetURL += "&hideCountryLabel=" + document.cbform4.mycheckbox.checked;
targetURL += "&altchart=" + altchart;



location.replace(targetURL);

return false;
}
timer=setTimeout('reloadPage()', 10000);
</script>

</form>


Finally a chart was added to the report which displays Product Line or Product details based on the altchart parameter set in the reload script. This was accomplished by using the DE API within the beforeFactory script to swap the chart data set as shown below.

graph = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("Chart1");
var request = reportContext.getHttpServletRequest();
altchart=2;
if( request.getParameter("altchart")){
altchart = request.getParameter("altchart").toString();
}
if( altchart == "2" ){
graph.setProperty( "dataSet", "graph2" );
}else{
graph.setProperty( "dataSet", "graph1" );

}


This report can be downloaded here.

12 comments:

Anonymous said...

Hi Jason!

BIRT becomes better and better with each release, nice work! Some questions: do you know when the support of new BIRT 2.2 features will be available in Actuate's BusinessReports? I saw a demo of BR ad-hoc ant it seems very powerfull. Does it cover 100% of functionality that is available in Eclipse's design time?

Regards,
Alex Key

Anonymous said...

is there any way i could show/hide the columns without reloading the report as the data is already present?

Jason Weathersby said...

Alex,

I sent an email to some of the guys on the BusinessReports team.
They should post a response.

Jason

Jason Weathersby said...

You can re render the report without re execution by setting the overwrite to false in the reload script.

Jason

Anonymous said...

OK!

Regards,
Alex Key

Anonymous said...

Hi Jason!

Any news from Actuate?

Regards,
Alex Key

Jason Weathersby said...

Alex,

I apologize for the delay. I thought someone had already responed to you. I am not sure when those features will make it into BRS (I spend most of my time on OS BIRT), but I would imagine they will make it in either Actuate 10, or a service pack after June. If you want I can get you an email address of someone who knows more. Send me an email at jasonweathersby at alltel.net
Thanks

Jason

Anonymous said...

Hi Alex,

The BIRT designer is for developers and the BusinessReports Studio is for the Business and Power users so each has its own set of capabilities and strengths. Is there a particular feature that you hope makes it in? Email me at vdodson at actuate.com and we can discuss some of the differences.

Virgil

Yvonne Mwajuma said...

Part of my report has pre-checked checkboxes.
When I run my report, I can view the pre-checked checkboxes, but when I print to pdf, I do not see them. Any idea how to do this?

Jason Weathersby said...

Currently exporting to pdf does not support adding check boxes. It would be good to log an enhancement for this. If you have access to the pdf you could look at calling iText functions to add them as well:
http://www.geek-tutorials.com/java/itext/itext_acroform_javascript.php

Anonymous said...

Hi Jason, I was wondering if this solution can be tweaked to show/hide the datarow in the report instead of the column?
I am exploring a solution for a requirement where in user selects the datarow from the generated report and on clicking a button or something we export only the selected datarows to a PDF/XLS.

Your input on this will be highly helpful.
Thanks in advance !

-Rohit

Sanela Tutaris said...

The report DOES NOT WORK if uploaded to Maximo...if you do this:
"You can re render the report without re execution by setting the overwrite to false in the reload script."
Jason, do you have any solutions please to make it work in Maximo too?