org.apache.wicket.extensions.wizard
Class WizardModel

java.lang.Object
  extended by org.apache.wicket.extensions.wizard.AbstractWizardModel
      extended by org.apache.wicket.extensions.wizard.WizardModel
All Implemented Interfaces:
java.io.Serializable, IWizardModel, IClusterable

public class WizardModel
extends AbstractWizardModel

Default implementation of IWizardModel, which models a semi-static wizard. This means that all steps should be known upfront, and added to the model on construction. Steps can be optional by using WizardModel.ICondition. The wizard is initialized with a wizard model through calling method Wizard.init(IWizardModel).

Steps can be added to this model directly using either the normal add method or the conditional add method.

Swing Wizard Framework served as a valuable source of inspiration.

Author:
Eelco Hillenius
See Also:
Serialized Form

Nested Class Summary
static interface WizardModel.ICondition
          Interface for conditional displaying of wizard steps.
 
Field Summary
static WizardModel.ICondition TRUE
          Condition that always evaluates true.
 
Constructor Summary
WizardModel()
          Construct.
 
Method Summary
 void add(IWizardStep step)
          Adds the next step to the wizard.
 void add(IWizardStep step, WizardModel.ICondition condition)
          Adds an optional step to the model.
protected  boolean allStepsComplete()
          Returns true if all the steps in the wizard return true from IWizardStep.isComplete().
protected  IWizardStep findLastStep()
          Finds the last step in this model.
protected  IWizardStep findNextVisibleStep()
          Finds the next visible step based on the active step.
 IWizardStep getActiveStep()
          Gets the current active step the wizard should display.
 boolean isLastAvailable()
          Checks if the last button should be enabled.
 boolean isLastStep(IWizardStep step)
          Gets whether the specified step is the last step in the wizard.
 boolean isNextAvailable()
          Checks if the next button should be enabled.
 boolean isPreviousAvailable()
          Checks if the previous button should be enabled.
 void last()
          Takes the model to the last step in the wizard.
 void next()
          Increments the model to the next step.
 void previous()
          Takes the model to the previous step.This method must only be called if IWizardModel.isPreviousAvailable() returns true.
 void reset()
          Resets the model, setting it to the first step.
 void setActiveStep(IWizardStep step)
          Sets the active step.
 java.util.Iterator stepIterator()
          Returns an iterator over all the steps in the model.
 
Methods inherited from class org.apache.wicket.extensions.wizard.AbstractWizardModel
addListener, cancel, finish, fireActiveStepChanged, fireWizardCancelled, fireWizardFinished, isCancelVisible, isLastVisible, removeListener, setCancelVisible, setLastVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRUE

public static final WizardModel.ICondition TRUE
Condition that always evaluates true.

Constructor Detail

WizardModel

public WizardModel()
Construct.

Method Detail

add

public void add(IWizardStep step)
Adds the next step to the wizard. If the WizardStep implements WizardModel.ICondition, then this method is equivalent to calling add(step, (ICondition)step).

Parameters:
step - the step to added.

add

public void add(IWizardStep step,
                WizardModel.ICondition condition)
Adds an optional step to the model. The step will only be displayed if the specified condition is met.

Parameters:
step - The step to add
condition - the WizardModel.ICondition under which it should be included in the wizard.

getActiveStep

public final IWizardStep getActiveStep()
Gets the current active step the wizard should display.

Returns:
the active step.

isLastAvailable

public boolean isLastAvailable()
Checks if the last button should be enabled.

Returns:
true if the last button should be enabled, false otherwise.
See Also:
IWizardModel.isLastVisible()

isLastStep

public boolean isLastStep(IWizardStep step)
Description copied from interface: IWizardModel
Gets whether the specified step is the last step in the wizard.

Parameters:
step - the step to check
Returns:
True if its the final step in the wizard, false< otherwise.
See Also:
IWizardModel.isLastStep(org.apache.wicket.extensions.wizard.IWizardStep)

isNextAvailable

public boolean isNextAvailable()
Checks if the next button should be enabled.

Returns:
true if the next button should be enabled, false otherwise.

isPreviousAvailable

public boolean isPreviousAvailable()
Checks if the previous button should be enabled.

Returns:
true if the previous button should be enabled, false otherwise.

last

public void last()
Description copied from interface: IWizardModel
Takes the model to the last step in the wizard. This method must only be called if IWizardModel.isLastAvailable() returns true. Implementors should notify listeners through calling IWizardModelListener.onActiveStepChanged(IWizardStep).

See Also:
IWizardModel.last()

next

public void next()
Description copied from interface: IWizardModel
Increments the model to the next step. This method must only be called if IWizardModel.isNextAvailable() returns true. Implementors should notify listeners through calling IWizardModelListener.onActiveStepChanged(IWizardStep).

See Also:
IWizardModel.next()

previous

public void previous()
Description copied from interface: IWizardModel
Takes the model to the previous step.This method must only be called if IWizardModel.isPreviousAvailable() returns true. Implementors should notify listeners through calling IWizardModelListener.onActiveStepChanged(IWizardStep).

See Also:
IWizardModel.previous()

reset

public void reset()
Description copied from interface: IWizardModel
Resets the model, setting it to the first step. Implementors should notify listeners through calling IWizardModelListener.onActiveStepChanged(IWizardStep).

See Also:
IWizardModel.reset()

setActiveStep

public void setActiveStep(IWizardStep step)
Sets the active step.

Parameters:
step - the new active step step.

stepIterator

public final java.util.Iterator stepIterator()
Description copied from interface: IWizardModel
Returns an iterator over all the steps in the model. The iteration order is not guaranteed to the be the order of traversal. This is an optional operation; dynamic models can just return null, and should call init the first time a step is encountered right before rendering it.

Returns:
an iterator over all the steps of the model or null if the wizard model is not static
See Also:
IWizardModel.stepIterator()

allStepsComplete

protected final boolean allStepsComplete()
Returns true if all the steps in the wizard return true from IWizardStep.isComplete(). This is primarily used to determine if the last button can be enabled.

Returns:
true if all the steps in the wizard are complete, false otherwise.

findLastStep

protected final IWizardStep findLastStep()
Finds the last step in this model.

Returns:
The last step

findNextVisibleStep

protected final IWizardStep findNextVisibleStep()
Finds the next visible step based on the active step.

Returns:
The next visible step based on the active step


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.