The Source for Java Technology Collaboration


Wizard Controller and Wizard Transitions

The wizard controller extends the pre-defined Wizard class and controls wizard execution. The controller of Signup Wizard defines references to all wizard steps, exposing them as properties. Steps can be looked up by their names, as well.


    final StepSignup stepSignup;
    public StepSignup getStepSignup() {return stepSignup;}

    final StepDetails stepDetails;
    public StepDetails getStepDetails() {return stepDetails;}

    final IWizardStep stepConfirm;
    public IWizardStep getStepConfirm() {return stepConfirm;}
  
    ...

    stepSignup = new StepSignup(this, "Signup Node");
    stepDetails = new StepDetails(this, "Details Node");
    stepConfirm = new StepConfirm(this, "Confirmation Node");

    // Starting off the Signup node
    sourceState = stepSignup;

While a step is usually defined in a separate file, a transition can be defined as anonymous class, because it has only one method to override: validate.


    // Path from identification node to personalization node.
    // Will be chosen if name and password are valid and a user
    // elected to enter personal information.
    stepSignup.addOutgoingTransition(
        new WizardTransition(this, "Signup To Detail", stepDetails) {
            public boolean validate() {
                return
                    stepSignup.getPersonalize() &&
                    stepSignup.validateNameAndPassword();
            }
        }
    );

    // Path from identification node to confirmation node. Will be chosen
    // if name and password are valid and a user did not elect to enter
    // personal information.
    stepSignup.addOutgoingTransition(
        new WizardTransition(this, "Signup To Confirmation", stepConfirm) {
            public boolean validate() {
                return stepSignup.validateNameAndPassword();
            }
        }
    );

    // Path from personalization node to confirmation node
    // Will be chosen if both book and movie are non null values.
    stepDetails.addOutgoingTransition(
        new WizardTransition(this, "Detail To Confirmation", stepConfirm) {
            public boolean validate() {
                if ( stepDetails.getSecurityAnswerId() > -1 &&
                    stepDetails.getSecurityAnswer() != null &&
                    stepDetails.getSecurityAnswer().trim().length() > 0) {
                    return true;
                } else {
                    wizard.getWizardErrors().put(
                         "loginsignupcontrol.nosecurityinfo", null);
                    return false;
                }
            }
        }
    );

Topic EasyWizardTransitions . { Edit | Ref-By | Printable | Diffs r2 < r1 | More }
 XML java.net RSS

Revision r2 - 21 Jul 2005 - 21:45:05 - Main.michael_jouravlev
Parents: WebHome > EasyWizard > EasyWizardDocumentation