Java Reference
In-Depth Information
indexes into the wizard tasks sequence and maps the WizardItem to a task
name. When the user finishes all the tasks, the WizardItem 's instance variable,
complete , function is invoked. If the user selects the Cancel button, the Wizard-
Item 's instance variable, cancel , function is called. An example of creating a
wizard is shown in Listing 12.16.
Listing 12.16
Wizard Object Literal
Wizard {
currentItem : root
tasks : ["Customer", "Ship To", "Contact", "Delivery"]
cancel : function() {
...
}
complete : function() {
...
}
}
Notice that the currentItem is set to the starting WizardItem named root in this
example. Each WizardItem contains a node that holds a generic javafx.scene
.Node object that is displayed in the middle of the Wizard window when the
WizardItem is selected. Each WizardItem also contains a taskId integer vari-
able that maps the item to a task defined in the wizard. When the WizardItem is
selected, this causes the appropriate node on the progress indicator to be high-
lighted. In addition, the WizardItem may contain a message that will be dis-
played above the wizard buttons.
The WizardItem has an instance variable, next , that holds a function for deter-
mining the next wizard item when the user selects the Next button. In conjunc-
tion with this, the variable nextItems holds a sequence of the possible next
WizardItem s. In a simple case, this will only contain one WizardItem . In a com-
plex case, this may contain multiple items and represent alternative paths that
may be chosen based on user input. By default, next is set to a function that
returns the first item from the nextItems sequence. This covers the simple case
of one item sequentially after another. If there are alternative paths or if special
processing is required before advancing to the next item, a custom next function
may be defined to determine the next WizardItem .
An example WizardItem object literal is shown in Listing 12.17. In this example,
the node is a CustomerAddressControl that extends javafx.scene.control
.Control . This item maps to the first task in Wizard, “Customer” by using the
 
Search WWH ::




Custom Search