api.script.ScriptException;
import org.eclipse.birt.report.engine.api.script.eventadapter.
ScriptedDataSetEventAdapter;
import org.eclipse.birt.report.engine.api.script.instance.
IDataSetInstance;
public class ScriptedDataSetHandler extends
ScriptedDataSetEventAdapter {
private int currentCount;
@Override
public boolean fetch(IDataSetInstance dataSet, IUpdatableDataSetRow
row) {
//increment the counter
currentCount++;
if (currentCount < 11)
{
//set the rows value
try {
row.setColumnValue("cnt", currentCount);
} catch (ScriptException e) {
e.printStackTrace();
}
return true;
}
return false;
}
@Override
Scripting and Event Handling
[ 252 ]
public void open(IDataSetInstance dataSet) {
super.open(dataSet);
//initialize the count
currentCount = 0;
} }
Now, I have to restart Eclipse in order for it to recognize the class in my Report
Design. Then, once I restart Eclipse, I am able to use my class and debug in Eclipse
when I run the report. Next, I go into the Report Design, select my dsCount Data
Source, and clear all of the Script out of the Events. Then, under the Event Handler
tab, I click on the browse button, and select my class. When I run the report, it will
use my new class as the Event Handler.
The benefit to this approach is that it is much easier to debug during development.
Pages:
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205