Você está na página 1de 6

Internet

Debugging Birt Javascript


Abstract
I was creating a report in order to answer a query that had been raised by a reader of BIRT for Beginners where they needed to use the List Box parameter within a report In order to do this with BIRT I needed to use some Javascript in the beforeOpen event of m

By Paul Bappoo

Ukraine October 04, 2010

Content provided by Article Niche


Copyright 2011 Paul Bappoo - All Rights Reserved. Hyperlinked material remains the property of its respective owners.

| Debugging Birt Javascript

I was creating a report in order to answer a query that had been raised by a reader of BIRT for Beginners where they needed to use the List Box parameter within a report. In order to do this with BIRT I needed to use some Javascript in the beforeOpen event of my data set and I had a problem with the creation of this script. So I needed to find a way to examine the values of variables while the script was running to see what I was dealing with and where my error was coming from. There are ways to switch on logging from BIRT and dropping values out to a log file, which you can exaine after an execution, but this is a little long winded for quickly creating and debugging snippets of Java code, so I wanted to find a faster, more immediate way to interrogate my script variables. Looking around on the web I came across a method that involves running BIRT in the console mode, which means that you get all output from your script generated immediately to a console window. This is great because it means that you can tweak your script and learn the results immediately, making debugging a quick and efficient process. CONSOLE MODE First we need to launch BIRT in Console mode, so we get to see our console window alongside the main BIRT IDE. Do this by running eclipsec.exe, using a command line like this: "C:BIRT 251eclipsec.exe" Notice that this is different to the usual eclipse.exe with the addition of the letter "c", you will notice that BIRT runs in the normal way, but with a console available too. THE BASIC REPORT To demonstrate the use of the console window for output, create a simple listing report based on any data set that you choose. For my example I used the ClassicModels customer table and just listed out all customers. ACCESSING THE SCRIPT AREA Next I created a small piece of script in my report, which simply setup a for loop, to display a counter. There are various areas within a BIRT report where you can

Article Niche Content Provider

access the scripting area so for our example I am going to use the data set. Select your data set and then click on the script tab at the bottom of the main layout window, ensure that beforeOpen is the selected script event. GENERATING OUTPUT TO THE CONSOLE Enter this script: for(int i=1; i<11; i++) { Packages.java.lang.System.out.println ("Count is: " + i); } This would seem to set up a for loop to increment a variable (i) value and stop when the value of i reaches 11, then print the value of i to the console window. But it contains an error. Run your report and you should see the console window displays the error message: The full version of this report, including screen shots and source code, in full colour pdf is available for free download at http://www.BIRTReporting.com To fix the script, change the reserved word "int" on line 1 to declare the i variable correctly, as follows: for(var i=1; i<11; i++) { Packages.java.lang.System.out.println ("Count is: " + i); } The important thing to notice here, is that we have returned the value of the variable i to the console window while the report was running. This can of course be applied to any variable that you have in your script and should help with your scripting and debugging efforts. MORE INFORMATION BIRT for Beginners, written by Paul Bappoo, the founder of the BIRT User Group UK presents an overview of the open source BIRT tools and the commercial enhancements available from Actuate, including... &bull; Eclipse BIRT Designer

Article Niche Content Provider

&bull; &bull; &bull; &bull; &bull;

Actuate BIRT Designer iServer Express Interactive BIRT viewer Actuate BIRT Studio BIRT Spreadsheet Designer

With walkthrough tutorials of the main features, including screenshots, from installation through data selection to formatting reports and fully graphical Flash charting this book will have you creating your own reports from scratch in only a couple of hours. If you are too busy to spend days learning software and want tangible results fast then BIRT For Beginners is for you.

Article Niche Content Provider

References

Article Niche Content Provider

About The Author


Paul Bappoo is the author of BIRT for Beginners (which is available in paperback from BIRTReporting.com, Amazon and Barnes and Noble amongst others) and the BIRT for Maximo Self Study Workbook, also available from BIRTReporting.com. He has been an international technical software consultant and involved with computers for over 30 years. Paul has an interest in BIRT reporting, enterprise application integration, automated software testing, computer based training and enterprise system implementation. Paul runs the BIRT User Group UK and is a member of the BIRT-Exchange Advisory Council. He would be delighted to hear from you with your tips, tricks and stories about your usage of BIRT. If you have a question, a need for training or consulting or great tip to share with the community then drop him a line. Paul Bappoo is the author of BIRT for Beginners (which is available in paperback from BIRTReporting.com, Amazon and Barnes and Noble) and has been an international technical software consultant and involved with computers for over 30 years. Paul has an interest in BIRT reporting, enterprise application integration, automated software testing, computer based training and enterprise system implementation. Paul runs the BIRT User Group UK and is a member of the BIRT-Exchange Advisory Council. He would be delighted to hear from you with your tips, tricks and stories about your usage of BIRT. If you have a question, a need for training or consulting or great tip to share with the community then drop him a line.

Article Niche Content Provider

Você também pode gostar