setGlobalVariable("currentCount", currentCount);
return true;
}
return false;
7. In the Report Designer, drag over the dsCount Data Source to the
Report Designer.
8. Run the report.
Chapter 10
[ 251 ]
In the example just shown, we did a few things interestingly. First, we created the
Scripted Data source. The way this works is that the fetch method needs to return
true when data is returned and false when data is not returned, to get data into
the returned row into the cnt column. Then we are using the reportContexts.
setGlobal variable to keep track of the running count.
Using Java Objects as Event Handlers
The last thing we are going to look at in this chapter is using Java objects as
Event Handlers instead of JavaScript in the Script Editor. In order to implement
Java-based Event handlers, the designer needs to extend the appropriate Event
Handler object. For example, if we are going to implement the last example as a
Java object, we will need to extend the org.eclipse.birt.report.engine.api.
script.eventadapter.ScriptedDataSetEventAdapter class. So, to do this,
I created a separate Java project in Eclipse. I created a class like the following:
package com.birtbook.eventHandler;
import org.eclipse.birt.report.engine.api.script.IUpdatableDataSetRow;
import org.eclipse.birt.report.engine.
Pages:
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204