Show TOC

Procedure documentationStep 3: Creating Conditions Locate this document in the navigation structure

 

Conditions can be added to transitions to determine whether the navigation defined in the transition occurs.

In a transition, you specify a button, a condition, a source pane and a target pane. If the user clicks the button in the source pane, the wizard navigates to the target pane only if the condition is true. If no condition is specified (that is, null), the transition always occurs if the button is clicked.

For more information on transitions, see Step 2: Creating the Wizard Component.

Procedure

  1. Create a new class that implements ICondition.

  2. Implement isTrue(), which has the following signature:

    Syntax Syntax

    1. public boolean isTrue(IWizardContext ctx) {
      
      }
      
    End of the code.
Using Conditions

The following describes how to use the ICondition class:

  1. When creating transitions in your wizard component, create an instance of the condition class, as in the following example:

    Syntax Syntax

    1. IsStudent stuCond = new IsStudent();
    End of the code.
  2. If needed, create another condition class that checks if the original condition is false, as in the following example:

    Syntax Syntax

    1. ICondition notStuCond = new IsStudent() {
          public boolean isTrue(IWizardContext ctx) {
              return !super.isTrue(ctx);
          }
      };
      
    End of the code.
  3. Specify the condition in a transition. In the following example, the Next button on the personal details pane navigates to the student pane if the user is a student, and to the address pane if the user is not a student:

    Syntax Syntax

    1. wizard.addTransition(PersonalDetailsPane.PERSONAL_DETAILS_PANE_KEY,
          NEXT, stuCond, StudentPane.STUDENT_PANE_KEY);
      
      wizard.addTransition(PersonalDetailsPane.PERSONAL_DETAILS_PANE_KEY,
          NEXT, notStuCond, AddressPane.ADDRESS_PANE_KEY);
      
    End of the code.