11. Run the report. The Data element that was bound to valueFromScript will
show whatever you put in as your parameter value.
12. After running the report, modify the initialize method as follows:
valueFromScript = reportContext.getParameterValue("accessMe");
13. Run the report.
Scripting and Event Handling
[ 246 ]
In the last modification, we didn't use a local Context. Instead, we used the global
reportContext to access the Reports Parameters. The reportContext is accessible
in all of the Event Handlers, and can be used to set and get global variables, access
the HTTPServletRequest object, and access Report Engine variables (such as
the Output Format, the Application Context, Render Options, and the Report
Design Object).
Adding Elements to Reports
Next, let's look at using the reportContext to add a new element to the report.
In order to do this, we only need to change the initialize method from the last
example with the following code:
valueFromScript = reportContext.getParameterValue("accessMe") + "
modified";
//import the needed packages from the Java API
importPackage(Packages.org.eclipse.birt.report.model.api);
importPackage(Packages.org.eclipse.birt.report.model.api.elements);
//using the report context, get the design handle
design = reportContext.getReportRunnable().designHandle;
//get the element factory to create the new label
elementFactory = design.
Pages:
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198