Select getCustomerOrders from the Outline. From the Event drop-down,
select beforeOpen. Use the following code to initialize the globalCount
variable:
globalCount = 0;
Scripting and Event Handling
[ 244 ]
7. From the Event drop-down, select onFetch. Use the following code to
increment the counter:
globalCount++;
8. Open the Report Designer Layout tab. Drag a Data element to the bottom of
the Report Design. Use the following Expression:
globalCount
9. Run the report.
Understanding the order of execution is important. The report's initialize method
will get executed before any of the other methods. Next, the data set gets generated
in the data transform phase. And finally, the value of globalCount gets inserted into
the data element we dropped into the report design in the factory phase.
Contexts
From any of the Report Generation Phases, you have access to various Contexts. For
the most part, each of the five Phases has its own context; in addition, there are also a
few extra Contexts??”one for the Data Row, and one for displaying an element.
In BIRT, Contexts are used to access objects within the Scripting environment. At
a very high level, you have access to the Report Context. The Report Context is a
mapping in the BIRT Scripting environment to the Java object IReportContext,
inside of the org.
Pages:
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196