com.sun.webui.jsf.model
Class WizardModelBase

java.lang.Object
  extended by com.sun.webui.jsf.model.WizardModelBase
All Implemented Interfaces:
WizardModel, javax.faces.component.StateHolder

public class WizardModelBase
extends java.lang.Object
implements WizardModel

WizardModelBase is the default WizardModel instance used by the Wizard. This class's behavior supports wizard functionality as defined by "Web Application Guidelines - Version 3.0". The support for a step list as defined by the guidelines is encapsulated in WizardStepListBase. This class maintains state, controls navigation, and expects the existence of finish and results wizard steps. In addition this class can control whether or not steps should participate in JSF lifecycle phases, see decode, validate, and update.

WizardModelBase expects a hierachy of WizardStep, WizardBranch, WizardBranchSteps, and WizardSubstepBranch components. This hierarchy can be specified as children of the Wizard component or as a list returned by Wizard.getSteps(). If getSteps does not return null, the steps represented by that value takes precedence over the existence of Wizard child components.

The Wizard component calls the initialize method twice during the request lifecycle. Once during the RESTORE_VIEW phase, and once during the RENDER_RESPONSE phase. This is necessary so the model can re-evaluate the steps if changes have occured during request processing or in the INVOKE_APPLICATION phase, which occur before the RENDER_RESPONSE phase. On the first display of a wizard, the initialize method is only called once during the RENDER_RESPONSE phase.
Note that a call to initialize during RESTORE_VIEW phase is only relevant when the application is configured in client side state saving mode.

When the wizard receives events due to a user clicking one of the navigation components, it calls handleEvent with the corresponding event and data.

The wizard will call the complete method to indicate to the model that it considers the wizard session to be over and will no longer reference it during this wizard session, and that it is free to deallocate any resources.


Constructor Summary
WizardModelBase()
          Construct a WizardModelBase instance.
 
Method Summary
 boolean canGotoStep(WizardStep step)
          Return true if the user can navigate to step out of sequence, else false.
 void complete()
          Called to inform the model that this instance will no longer be referenced.
 boolean decode(int event, boolean prematureRender)
          Returns false if prematureRender is true, else true if the step should participate in the APPLY_REQUEST_VALUES phase.
 WizardStep getCurrentStep()
          Return the current WizardStep instance.
 WizardStep getFirstStep()
          Return the first WizardStep instance.
 WizardStep getLastStep()
          Return the last WizardStep instance.
 WizardStep getNextStep(WizardStep step)
          Return the WizardStep instance following step.
 java.lang.String getPlaceholderText(WizardStep step)
          Return a description of this WizardBranch step.
 WizardStep getPreviousStep(WizardStep step)
          Return the WizardStep instance preceding step If there is no previous step return null.
 java.util.Iterator getWizardStepIterator()
          Based on the current state of the Wizard, return an Iterator of the current sequence of WizardStep instances.
 WizardStepList getWizardStepList()
          Return a WizardStepList of WizardStepListItem instances.
 boolean handleEvent(WizardEvent event)
          Handle the following WizardEvent events and adjust the state accordingly.
 boolean hasCancel(WizardStep step)
          Return true if the cancel button should be rendered for this step, else false.
 boolean hasClose(WizardStep step)
          Return true if the close button should be rendered for this step, else false.
 boolean hasFinish(WizardStep step)
          Return true if the finish button should be rendered for this step, else false.
 boolean hasNext(WizardStep step)
          Return true if the next button should be rendered for this step, else false.
 boolean hasPrevious(WizardStep step)
          Return true if the previous button should be rendered for this step, else false.
 boolean hasStepHelp()
          Return true if any of the steps have step help.
 void initialize(Wizard wizard)
          Initialize the current set of WizardSteps.
 boolean isBranch(WizardStep step)
          Return true if step is a branching step, else false.
 boolean isCancelDisabled(WizardStep step)
          Return true if the cancel button should be disabled for this step, else false.
 boolean isCloseDisabled(WizardStep step)
          Return true if the close button should be disabled for this step, else false.
 boolean isComplete()
          Return true if the wizard has completed and there are no more steps for the user to complete, else false.
 boolean isCurrentStep(WizardStep step)
          Return true if step is the current step, else false.
 boolean isFinishDisabled(WizardStep step)
          Return true if the finish button should be disabled for this step, else false.
 boolean isFinishStep(WizardStep step)
          Return true if step is the step the should contain a Finish button.
 boolean isNextDisabled(WizardStep step)
          Return true if the next button should be disabled for this step, else false.
 boolean isPreviousDisabled(WizardStep step)
          Return true if the previous button should be disabled for this step, else false.
 boolean isResultsStep(WizardStep step)
          Return true if step is the results step, else false.
 boolean isSubstep(WizardStep step)
          Return true if step is a substep step, else false.
 boolean isTransient()
          StateHolder method indicating the this class is persistent.
 void restoreState(javax.faces.context.FacesContext context, java.lang.Object state)
          StateHolder method called to restore the model's current state based on the values in state.
 java.lang.Object saveState(javax.faces.context.FacesContext context)
          StateHolder method called to save the state the model's state.
 void setTransient(boolean transientFlag)
          StateHolder method to set the persistent state of this class.
 boolean update(int event, boolean prematureRender)
          Return true if the current step should participate in the UPDATE_MODEL_VALUES phase.
 boolean validate(int event, boolean prematureRender)
          Return true if the current step should participate in the PROCESS_VALIDATIONS phase.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WizardModelBase

public WizardModelBase()
Construct a WizardModelBase instance. The initialize method must be called with the wizard instance when the step children are available. The Wizard instance will call this method at the appropriate time.

Method Detail

initialize

public void initialize(Wizard wizard)
Initialize the current set of WizardSteps. This method is called by the Wizard twice. Once during RETORE_VIEW phase, and once during RENDER_RESPONSE phase. This sequence affords the model the opportunity to modify its state due to changes that may have occured during request processing.
Note that a call during RESTORE_VIEW phase is only relevant when the application is configured in client side state saving mode.

Specified by:
initialize in interface WizardModel
Parameters:
wizard - The Wizard component.

getWizardStepIterator

public java.util.Iterator getWizardStepIterator()
Based on the current state of the Wizard, return an Iterator of the current sequence of WizardStep instances.

Specified by:
getWizardStepIterator in interface WizardModel

getWizardStepList

public WizardStepList getWizardStepList()
Return a WizardStepList of WizardStepListItem instances.

Specified by:
getWizardStepList in interface WizardModel

getFirstStep

public WizardStep getFirstStep()
Return the first WizardStep instance.

Specified by:
getFirstStep in interface WizardModel

getLastStep

public WizardStep getLastStep()
Return the last WizardStep instance. The step that is returned is dependent on the state of the wizard. It may only be the last step at this point in time. At a later point in time, it may be a different step, due to the existence of branch steps.


getNextStep

public WizardStep getNextStep(WizardStep step)
Return the WizardStep instance following step. If there are no more steps return null.

Specified by:
getNextStep in interface WizardModel
Parameters:
step - The step preceding the returned step.

getPreviousStep

public WizardStep getPreviousStep(WizardStep step)
Return the WizardStep instance preceding step If there is no previous step return null.

Specified by:
getPreviousStep in interface WizardModel
Parameters:
step - The step following the returned step.

getCurrentStep

public WizardStep getCurrentStep()
Return the current WizardStep instance.

Specified by:
getCurrentStep in interface WizardModel

isCurrentStep

public boolean isCurrentStep(WizardStep step)
Return true if step is the current step, else false.

Specified by:
isCurrentStep in interface WizardModel
Parameters:
step - The step to test.

isFinishStep

public boolean isFinishStep(WizardStep step)
Return true if step is the step the should contain a Finish button. This is the step that performs the wizard task with the data collected from previous steps.

Specified by:
isFinishStep in interface WizardModel
Parameters:
step - The step to identify.

isResultsStep

public boolean isResultsStep(WizardStep step)
Return true if step is the results step, else false. The Results step follows the Finish step and displays only a "Close" button. It displays results of the task performed in the Finish step.

Specified by:
isResultsStep in interface WizardModel
Parameters:
step - The step to identify.

isBranch

public boolean isBranch(WizardStep step)
Return true if step is a branching step, else false. A branching step acts as a step "placeholder" and informs the user that the steps following this step are determined by the data entered in this or previous steps. Text should be provided from the getPlaceHolderText method for this step, describing the branch.

Specified by:
isBranch in interface WizardModel
Parameters:
step - The step to identify.

getPlaceholderText

public java.lang.String getPlaceholderText(WizardStep step)
Return a description of this WizardBranch step.

Specified by:
getPlaceholderText in interface WizardModel
Parameters:
step - A branching step. It must be a WizardBranch instance.

isSubstep

public boolean isSubstep(WizardStep step)
Return true if step is a substep step, else false. A substep is a step or one of a series of substeps, that occurs in every instance of this wizard. Unlike the branch step, substep sequences are always the same but may or may not be performed based on previous steps.

Specified by:
isSubstep in interface WizardModel
Parameters:
step - The step to check.

canGotoStep

public boolean canGotoStep(WizardStep step)
Return true if the user can navigate to step out of sequence, else false. Typically this method is called to determine if a previous step should be rendered such that the user can select it and navigate back to that step. Its possible that some wizards may also allow forward navigation.

Note this method only supports navigating to steps occuring before the current step.

Specified by:
canGotoStep in interface WizardModel
Parameters:
step - The step to check.

isPreviousDisabled

public boolean isPreviousDisabled(WizardStep step)
Return true if the previous button should be disabled for this step, else false. Typically the first step of a sequence should return true, since there usually isn't a step before the first step.

Specified by:
isPreviousDisabled in interface WizardModel
Parameters:
step - The step to check.

isNextDisabled

public boolean isNextDisabled(WizardStep step)
Return true if the next button should be disabled for this step, else false. This method always returns false;

Specified by:
isNextDisabled in interface WizardModel
Parameters:
step - The step to check.

isFinishDisabled

public boolean isFinishDisabled(WizardStep step)
Return true if the finish button should be disabled for this step, else false. This method always returns false;

Specified by:
isFinishDisabled in interface WizardModel
Parameters:
step - The step to check.

isCancelDisabled

public boolean isCancelDisabled(WizardStep step)
Return true if the cancel button should be disabled for this step, else false. This method always returns false;

Specified by:
isCancelDisabled in interface WizardModel
Parameters:
step - The step to check.

isCloseDisabled

public boolean isCloseDisabled(WizardStep step)
Return true if the close button should be disabled for this step, else false. This method always returns false;

Specified by:
isCloseDisabled in interface WizardModel
Parameters:
step - The step to check.

hasPrevious

public boolean hasPrevious(WizardStep step)
Return true if the previous button should be rendered for this step, else false. Typically this method returns true for all steps except for steps that are results steps.

Specified by:
hasPrevious in interface WizardModel
Parameters:
step - The step to check.

hasNext

public boolean hasNext(WizardStep step)
Return true if the next button should be rendered for this step, else false. Typically this method returns true for all steps except for steps that are finish or results steps.

Specified by:
hasNext in interface WizardModel
Parameters:
step - The step to check.

hasCancel

public boolean hasCancel(WizardStep step)
Return true if the cancel button should be rendered for this step, else false. Typically this method returns true for all steps except for steps that are results steps.

Specified by:
hasCancel in interface WizardModel
Parameters:
step - The step to check.

hasClose

public boolean hasClose(WizardStep step)
Return true if the close button should be rendered for this step, else false. Typically this method returns true only for the results step.

Specified by:
hasClose in interface WizardModel
Parameters:
step - The step to check.

hasFinish

public boolean hasFinish(WizardStep step)
Return true if the finish button should be rendered for this step, else false. Typically this method returns true only for the finish step.

Specified by:
hasFinish in interface WizardModel
Parameters:
step - The step to check.

hasStepHelp

public boolean hasStepHelp()
Return true if any of the steps have step help. If any of the steps have step help, this method should return true, unless no step help should be shown for the wizard. If the determination had not been made when this method is called, since the step list must be built at least once, false is returned.

Specified by:
hasStepHelp in interface WizardModel

isComplete

public boolean isComplete()
Return true if the wizard has completed and there are no more steps for the user to complete, else false. Typically this informs the wizard that there is nothing more to render. This may cause a popup wizard to be dismissed or an inline wizard to navigate to some other page.

Specified by:
isComplete in interface WizardModel

complete

public void complete()
Called to inform the model that this instance will no longer be referenced.

Specified by:
complete in interface WizardModel

decode

public boolean decode(int event,
                      boolean prematureRender)
Returns false if prematureRender is true, else true if the step should participate in the APPLY_REQUEST_VALUES phase.

Specified by:
decode in interface WizardModel
Parameters:
event - The event that precipitated this call.
prematureRender - true if rendering is occuring before RENDER_RESPONSE phase was normally expected.

validate

public boolean validate(int event,
                        boolean prematureRender)
Return true if the current step should participate in the PROCESS_VALIDATIONS phase. Returns true if event is WizardEvent.NEXT or WizardEvent.FINISH and prematureRender is false.

Specified by:
validate in interface WizardModel
Parameters:
event - The event that precipitated this call.
prematureRender - Is true if rendering is occuring before RENDER_RESPONSE phase was normally expected.

update

public boolean update(int event,
                      boolean prematureRender)
Return true if the current step should participate in the UPDATE_MODEL_VALUES phase. Returns true if event is WizardEvent.NEXT or WizardEvent.FINISH and prematureRender is false.

Specified by:
update in interface WizardModel
Parameters:
event - The event that precipitated this call.
prematureRender - true if rendering is occuring before RENDER_RESPONSE phase was normally expected.

handleEvent

public boolean handleEvent(WizardEvent event)
Handle the following WizardEvent events and adjust the state accordingly.
  • WizardEvent.CANCEL
  • WizardEvent.CLOSE
  • WizardEvent.FINISH
  • WizardEvent.GOTOSTEP
  • WizardEvent.HELPTAB
  • WizardEvent.NEXT
  • WizardEvent.PREVIOUS
  • WizardEvent.STEPSTAB

Specified by:
handleEvent in interface WizardModel

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext context)
StateHolder method called to save the state the model's state. The saved state consists of the values of state, currentStep, and hasStepHelp of the internal WizardState instance.

Specified by:
saveState in interface javax.faces.component.StateHolder

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         java.lang.Object state)
StateHolder method called to restore the model's current state based on the values in state. The restored state consists of values for state, currentStep, and hasStepHelp of the internal WizardState instance.

Specified by:
restoreState in interface javax.faces.component.StateHolder

setTransient

public void setTransient(boolean transientFlag)
StateHolder method to set the persistent state of this class. This call does not modify this class.

Specified by:
setTransient in interface javax.faces.component.StateHolder

isTransient

public boolean isTransient()
StateHolder method indicating the this class is persistent. This method returns false

Specified by:
isTransient in interface javax.faces.component.StateHolder


Copyright © 2008 Sun Microsystems, Inc. All Rights Reserved.