| By Jason Weathersby | Article Rating: |
|
| July 26, 2010 12:38 PM EDT | Reads: |
4,281 |
One of the most common questions for people that are new to BIRT is about how to ask data from the DataSet in the report. The question is when building expressions should I use dataSetRow["FIELD"] or row["FIELD"]?
So let me see if I can set the record straight. When data is acquired, it is acquired by a DataSet, so the following query in a JDBC DataSet will create a three field resultset:
select CITY, STATE, COUNTRY
from CUSTOMERS
Any script or expressions written on the DataSet will be written to use the format

row["FIELD_NAME"];
So if we add a computed column to the DataSet called compCityState, the expression would look like this.
Once a computed column is created, you can reference that computed column using the same row syntax. So in the OnFetch method you could add this message to log the value of the computed column.
Packages.java.lang.System.out.println(row["compCityState"]);
The other place that you can access variable on the DataSet is through ReportItem binding. In most cases, this means Table Binding where you have attached a table to a DataSet. In general, when you use BIRT you associate a Table with a DataSet. We say that the Table is bound to the DataSet.
When a DataSet is dragged to the Layout editor, BIRT automatically does the data binding and creates a bound column for each field and computed column in the DataSet. The following shows a table and its Binding.
You will notice that all of the expressions use the term dataSetRow, which means this value is pulled from the DataSet. Now for the tricky bit, any field that is bound to a Table can be used in another table binding. So if we wanted to create a field that has City, State and Country, we could either:
a) go back to the DataSet
b) add a new table binding
When you add a binding to a table you are brought to the expression builder. In this first example, I am creating a table binding that gathers data straight from the DataSet.
So the short answer is, dataSetRow syntax references the original values from the DataSet, whereas the row syntax references the bound column values.
Now for a quick test, this should be easy.
Imagine that I change the expression of the CITY expression to look like this, and all else remains the same.
If the values for the row are:
City: Kalamazoo
State: MI
Country: USA
What will a DataItem that is showing rowCityStateZip display?
What will a DataItem that is showing tablCityStateCountry display?
The answers will be after a short shameless promotion of my companies BIRT training program. We have designed a modular training program that is focused on teaching you how BIRT works. You can take one module or all of them. The focus of our training is on how BIRT works, so that when you finish you really understand what is going on in the product.
Our training can be taken on-site, or through remote sessions of between two and four hours each. We are also happy to work with your team to customize the training to match your companies needs. If you are interested, please visit our web site and have a look.
Answers:
rowCityStateZip: { Kalamazoo }, MI USA
tablCityStateCountry: Kalamazoo, MI USA
Remember, dataSetRow syntax (as used in tablCityStateCountry) goes back to the original data. Row syntax use the table binding.
Read the original blog entry...
Published July 26, 2010 Reads 4,281
Copyright © 2010 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Jason Weathersby
Jason Weathersby is a member of the extended BIRT development team at Actuate Corporation and has backgrounds in both computer science and technical writing. He has many years experience in technical consulting, training, writing, and publishing about reporting, business intelligence tools, and database technologies.
- Book Excerpt: Introducing HTML5
- It's the Java vs. C++ Shootout Revisited!
- Patterns for Building High Performance Applications
- OpenXava 4.3: Rapid Java Web Development
- Asynchronous Logging Using Spring
- Java for Programmers (2nd Edition)
- Cross-Platform Mobile Website Development – a Tool Comparison
- Write Once Run Anywhere or Cross Platform Mobile Development Tools
- Three Buzzwords That Every CIO Hears but One They Should Listen To
- Immersing into JavaScript Frameworks
- Workday Reportedly Prepping to Go Public
- Book Review: Sams Teach Yourself Java in 24 Hours
- Book Excerpt: Introducing HTML5
- Adobe Sends Flex to the Apache Foundation
- Five Years Waiting for JRE 7: Is It Justified? (Part 1)
- Book Excerpt: Java Application Profiling Tips and Tricks
- i-Technology in 2012: Five Industry Predictions
- It's the Java vs. C++ Shootout Revisited!
- Patterns for Building High Performance Applications
- OpenXava 4.3: Rapid Java Web Development
- The Next Web Architecture
- Asynchronous Logging Using Spring
- Java for Programmers (2nd Edition)
- Is Write Once Run Anywhere Ever Going to Be a Reality?
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- JavaServer Faces (JSF) vs Struts
- The i-Technology Right Stuff
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- What's New in Eclipse?
- i-Technology Predictions for 2007: Where's It All Headed?

























