Class WizardModel
- java.lang.Object
-
- org.apache.wicket.extensions.wizard.AbstractWizardModel
-
- org.apache.wicket.extensions.wizard.WizardModel
-
- All Implemented Interfaces:
Serializable
,IWizardModel
,IClusterable
public class WizardModel extends AbstractWizardModel
Default implementation ofIWizardModel
, 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 usingWizardModel.ICondition
. The wizard is initialized with a wizard model through calling methodWizard.init(IWizardModel)
.Steps can be added to this model directly using either the
normal add method
orthe conditional add method
.Swing Wizard Framework served as a valuable source of inspiration.
- Author:
- Eelco Hillenius
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
WizardModel.ICondition
Interface for conditional displaying of wizard steps.
-
Field Summary
Fields Modifier and Type Field Description static WizardModel.ICondition
TRUE
Condition that always evaluates true.
-
Constructor Summary
Constructors Constructor Description WizardModel()
Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 fromIWizardStep.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.List<WizardModel.ICondition>
getConditions()
Gets conditions.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 ifIWizardModel.isPreviousAvailable()
returns true.void
reset()
Resets the model, setting it to the first step.void
setActiveStep(IWizardStep step)
Sets the active step.Iterator<IWizardStep>
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
-
Methods inherited from interface org.apache.wicket.extensions.wizard.IWizardModel
isFinishAvailable
-
-
-
-
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 theWizardStep
implementsWizardModel.ICondition
, then this method is equivalent to callingadd(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 addcondition
- theWizardModel.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.
- See Also:
IWizardModel.next()
-
isPreviousAvailable
public boolean isPreviousAvailable()
Checks if the previous button should be enabled.- Returns:
- true if the previous button should be enabled, false otherwise.
- See Also:
IWizardModel.previous()
-
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 ifIWizardModel.isLastAvailable()
returns true. Implementors should notifylisteners
through callingIWizardModelListener.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 ifIWizardModel.isNextAvailable()
returns true. Implementors should notifylisteners
through callingIWizardModelListener.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 ifIWizardModel.isPreviousAvailable()
returns true. Implementors should notifylisteners
through callingIWizardModelListener.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 notifylisteners
through callingIWizardModelListener.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 Iterator<IWizardStep> 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 visit. 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 fromIWizardStep.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
-
getConditions
public List<WizardModel.ICondition> getConditions()
Gets conditions.- Returns:
- unmodifiable list of conditions
-
-