Chapter 13: The Wizard Control, from Enterprise Curl, by Prentice Hall | 2 | WebReference

Chapter 13: The Wizard Control, from Enterprise Curl, by Prentice Hall | 2

Enterprise Curl: The Wizard Control

constructor

The WizardControl constructor method instantiates the class with the correct characteristics. The code for the constructor is listed in Figure 13–3.

FIGURE 13–3 WizardControl.constructor code listing. (continued)

FIGURE 13–3 WizardControl.constructor code listing.

The WizardControl has a number of private class attributes and one defined as public-get, which specifies a publicly readable field. Each standard access attribute, public, protected, package, and private, can be used with a -get and -set variant, and these would typically be used if the field could be read by a wider audience than could write to it. We saw in previous chapters how you can use the {getter} and {setter} methods to provide controlled access to a private declared class attribute; the -get and -set primitives are semantically equivalent to that approach.

The constructor method has two attributes: a title as a String and pages as an Array of WizardForms. Both of these attributes are immediately stored in class variable references, as they are used in other methods. The add-event-handler method is used to define the correct behavior for each of the Next, Back, and Cancel buttons.

The Cancel button uses the {popup-question} Curl system procedure to display a modal dialog window and continue processing based on the user's response. The {popup-question} procedure returns a Yes, No, or Cancel, dependent on which button is pressed; for instance, we execute the ancestor {close} method when the Yes button is clicked. The Dialog.{close} method accepts a String as a parameter, which is then set within the Dialog.return-state attribute and used by the calling process to determine how to proceed. In Chapter 14, we will see how the Dialog.return-state attribute is used within the VMSSheetManager object.

When the Next button is clicked, it determines if the current WizardForm page being displayed is the last one in the array. If it is the last page, then the {commit-return-message} is executed prior to the ancestor {close} method. If it is not the last page in the array, then the self.current-page counter is incremented and the {check-buttons} and {set-wizard-form} methods are executed. We will investigate the processing performed within these methods later in this chapter.

When the Back button is clicked, it decrements the self.current-page counter, and the {check-buttons} and {set-wizard-form} methods are executed.

The final line of the constructor calls the {create-window} method, which, as we will see, controls the physical layout of the wizard.

Created: May 2, 2003
Revised: May 2, 2003

URL: http://webreference.com/internet/enterprise/curl/chap13/2