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


Enterprise Curl: The Wizard Control


The {create-window} method is called from the {constructor} and is used to define the visual appearance of the wizard control. We saw the design layout for the wizard control in Figure 13Â2, which is realized by the code for the {create-window} method listed in Figure 13Â7.

The {create-window} method first calls the {set-wizard-form} method, which ensures that the first WizardForm page is displayed when the WizardControl is instantiated.

We then define a local HBox variable called layout, which acts as the container for each wizard control visual element. A key programmatic technique to focus on with the layout variable is the manner in which you can nest containers, such as a VBox or spaced-hbox, within one another. This is how we can realize the design layout described in Figure 13Â2. We make use of the {Rule} and {Fill} Curl system classes to ensure the layout appears correctly (these were described in previous chapters). The {hrule} text procedure also helps define an appealing layout; it creates a horizontal rule of any color you choose. It is particularly useful for separating sections on a layout.

FIGURE 13Â7 WizardControl.create-window code listing.

Because the {create-window} method is called from the {constructor}, it has to ensure that the Back, Next, and Cancel buttons have the correct labels and characteristics. This is done by calling the {check-buttons} method. Next, the ancestor {add} method is called, passing the layout variable as the argument, which displays the WizardControl to the user.


The WizardForm acts as a page to be contained within the WizardControl. It provides an API to create the appropriate display, obtain the chosen value selected, and set the value in the return message. The code for the WizardForm class is shown in Figure 13Â8.

The WizardForm class has the abstract modifier assigned in its declaration, because any Curl class that has at least one method declared abstract requires this. It has two class variables, both of which are declared as protected, because they will be accessed by descendent code. The protected primitive means that access is provided to code in the same package, as well as to sub-classes.

The {get-form} method is called from the WizardControl and returns the page layout as a VBox. This method will be overridden in the descendent classes, where the VBox will be populated with graphical elements relevant to the page being created.

FIGURE 13Â8 WizardForm code listing.

The {set-return-value} method has the abstract modifier assigned in its declaration, as no code will be implemented in the ancestor and a descendent class will be forced to implement this method. The Curl complier ensures that happens, and if you forget to write code for the {set-return-value} method in a sub-class, you will get a compiler error that says "sub-class inherited abstract method from WizardForm. set-return-value but sub-class is not declared abstract."

The {get-return-value} method returns the return-value attribute to the WizardControl, which then consolidates the value with all the other page values in a String that is returned to the calling process.

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