> Task 4: | Display the result using the ReportDesign.afterFactory( ) method

> To display the count of customers with the string Mini in their names, you insert code in a method that runs after the processing of all the rows in the table. One logical place for this code is in the ReportDesign.afterFactory( ) method.

> 1 | In Outline, select the report design, as shown in Figure 23‑9.

> Figure 23-9 | Selecting the report design in Outline

> 2 | Select the afterFactory( ) method from the script window drop-down list.

> 3 | Type the following code into the afterFactory( ) method:

> importPackage( Packages.javax.swing );
> countOfMinis = reportContext.getPersistentGlobalVariable("cmKey").intValue();
> frame = new JFrame( "Count of Minis = " + countOfMinis );
> frame.setBounds( 310, 220, 300, 20 );
> frame.show( );

> 4 | Select Preview to see the results. If there are no errors in the code, you see a report similar to the one in Figure 23‑10.

> Figure 23-10 | Result of changing the afterFactory( ) method

> If you do not see the Count of Minis window, look for it behind the Eclipse window. If the Count of Minis window does not appear, the most likely reason is a scripting error caused by an error in one of your code entries.

> If you suspect that a scripting error occurred, scroll to the bottom of the report where all scripting error messages appear. In most situations, there is a brief error message next to a plus sign ( + ). The plus sign indicates that there is a more detailed error message that is only visible after you expand the brief error message. To expand the brief error message, choose the plus sign. Scroll down to see the more detailed error message.

(c) Copyright Actuate Corporation 2008