> Task 2: | Create and initialize a counter in the Table.onCreate( ) method

> In order to count the number of customers whose names contain the string Mini, you must first declare a global counter and set its value to zero. The Table.onCreate( ) method is the most appropriate place to perform this task because Table.onCreate( ) executes before retrieving any rows. You conditionally increment this counter in the Row.onCreate( ) method.

> 1 | In Layout, select the table by placing the cursor near the bottom left corner of the table. The table icon appears, as shown in Figure 23‑5.

> Figure 23-5 | Table icon in the layout editor

> 2 | Choose the Script tab. The script tab appears, as shown in Figure 23‑6.

> o

> Figure 23-6 | Script window

> 3 | Type the following lines of code in the script window for the onCreate( ) method:

> countOfMinis = new Packages.java.lang.Integer("1");
> reportContext.setPersistentGlobalVariable("cmKey", countOfMinis);

> 4 | To run the report and verify that the code did not create any errors, choose Preview.

> 5 | Scroll to the bottom of the report, where JavaScript error messages appear. If there are no errors, the report appears, as shown in Figure 23‑7.

> If you see an error message, you may have typed a statement incorrectly. If so, go back to the script window, select the method you just modified, correct the error, and choose Preview again.

> Figure 23-7 | Report preview

(c) Copyright Actuate Corporation 2008