Previous Next

Using JavaScript to Write an Event Handler : Tutorial 7: Writing an event handler in JavaScript : Task 2: Create and initialize a counter in the Table.onCreate( ) method

Task 2:

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

Figure 23-5 Table icon in the layout editor

Figure 23-5
2

Figure 23-6 Script windowo

Figure 23-6
3
countOfMinis = new Packages.java.lang.Integer("1");
reportContext.setPersistentGlobalVariable("cmKey", countOfMinis);
4
5
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

Figure 23-7

(c) Copyright Actuate Corporation 2008