com.sri.emo.wizard.branch
Class BranchingWizard

java.lang.Object
  extended by com.sri.emo.wizard.AbstractWizard
      extended by com.sri.emo.wizard.branch.BranchingWizard
All Implemented Interfaces:
Wizard, Serializable
Direct Known Subclasses:
EmoCreationWizard

public class BranchingWizard
extends AbstractWizard

Title:

Description:

Copyright: Copyright (c) 2003

Company:

Version:
1.0
Author:
not attributable
See Also:
Serialized Form

Field Summary
(package private)  boolean finished
          Internal boolean flag -- if finished then page history's index will include the last page.
 
Constructor Summary
BranchingWizard(WizardMonitor wizMonitor, BranchNode[] steps)
          Constructor that takes a monitor and an array of steps.
 
Method Summary
 WizardPage backupToPage(Serializable pageKey)
          Allows programmatic rewinding to a previous page.
protected  void checkAgainstIllegalJump(int pageIndex)
          Checks that there were no illegally jumping forward moves caused by parameter manipulation.
protected  Integer convertKeyToPageId(Serializable pageId)
          Forgivingly converts page id to an internal integer.
 boolean equals(Object parm1)
          Override of Object.equals to check field by field.
protected  int findWizardPageIndex(WizardPage toFind)
          Find the wizard page index so we can define what the next page is.
 Map getAllData()
          Retrieve all the data for the wizard keyed by page id.
protected  BranchNode[] getAllSteps()
          Retrieve all the steps for the wizard.
 int getCurrentPageIndex()
          Retrieve the index of the current wizard.
protected  WizardPage getInitialPage()
          Retrieve the initial page for the wizard.
 List getMainStepHistory()
          Will return a history of steps without accounting for any of the branching
 WizardPage getPageById(Serializable s)
          Retrieve a page by a given id.
 List getStepHistory()
          Retrieve all Pages in the order that the person has stepped through them.
 int hashCode()
          Returns a hash code value for the object.
protected  boolean includeInMainStep(BranchNode node)
           
protected  boolean isNeedingRollback(WizardPage src)
          Checks the backtrace for presence of the given wizard page.
 WizardPage next(WizardPage src, Serializable newData)
          Execute the next page in the wizard.
 WizardPage next(WizardPage src, Serializable newData, Serializable allData)
          
protected  boolean onNextPage(WizardPage previousPage, WizardPage nextPage, Serializable previousPageData)
          Template method that gets called after the next page has been determined in the sequence.
 WizardPage previous()
          Backtracks the stack.
 Object processFinish(WizardPage src, Serializable data, Map additonalParams)
          Processes the final finish and returns some sort of data that can be whatever is desired.
protected  void rollbackBacktrace(WizardPage src)
          Rolls back the backtrace stack if the src page is already on the stack, indicating that the browser pushed the back button.
 String toString()
          Override of toString().
 
Methods inherited from class com.sri.emo.wizard.AbstractWizard
begin, destroy, getBackTrace, getCurrentPage, getId, getMonitor, getSummary, getTitle, setCurrentPage, setId, setSummary, setTitle
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

finished

boolean finished
Internal boolean flag -- if finished then page history's index will include the last page.

Constructor Detail

BranchingWizard

public BranchingWizard(WizardMonitor wizMonitor,
                       BranchNode[] steps)
Constructor that takes a monitor and an array of steps.

Parameters:
wizMonitor - the monitor for events occuring in the wizard.
steps - the WizardPage array ordered by the order they appear. Index 0 == first page.
Method Detail

getInitialPage

protected WizardPage getInitialPage()
Retrieve the initial page for the wizard.

Specified by:
getInitialPage in class AbstractWizard
Returns:
WizardPage instance.

getCurrentPageIndex

public int getCurrentPageIndex()
Retrieve the index of the current wizard. First page is page 1, Second Page is page 2, etc.

Returns:
int

next

public WizardPage next(WizardPage src,
                       Serializable newData,
                       Serializable allData)
                throws WizardException

The SequentialWizard implementation allows for the browser back button to be pressed and still achieve status quo. What happens is that if we detect that the browser back button was ealier pressed (we can tell because the src page parameter is already on the backtrace stack), then we rollback to the page previous to the src page and re-execute.

Parameters:
src - the wizard page source
newData - the data for the previous page.
Returns:
the next wizard page
Throws:
WizardException - upon error
ArrayIndexOutOfBoundsException - if next was clicked and there should be no next button (ie last page)

next

public WizardPage next(WizardPage src,
                       Serializable newData)
                throws WizardException
Execute the next page in the wizard.

The SequentialWizard implementation allows for the browser back button to be pressed and still achieve status quo. What happens is that if we detect that the browser back button was ealier pressed (we can tell because the src page parameter is already on the backtrace stack), then we rollback to the page previous to the src page and re-execute.

Specified by:
next in interface Wizard
Specified by:
next in class AbstractWizard
Parameters:
src - the wizard page source
newData - the data for the previous page.
Returns:
the next wizard page
Throws:
WizardException - upon error
ArrayIndexOutOfBoundsException - if next was clicked and there should be no next button (ie last page)

convertKeyToPageId

protected Integer convertKeyToPageId(Serializable pageId)
Forgivingly converts page id to an internal integer. Allowed parameters can be either Strings with integers or java.lang.Integer object.

Parameters:
pageId - Serializable the requested page id.
Returns:
int the converted value.

backupToPage

public WizardPage backupToPage(Serializable pageKey)
                        throws ArrayIndexOutOfBoundsException,
                               IllegalArgumentException
Allows programmatic rewinding to a previous page.

Parameters:
pageId - Serializable the page key.
Returns:
WizardPage the resulting page.
Throws:
ArrayIndexOutOfBoundsException
IllegalArgumentException

onNextPage

protected boolean onNextPage(WizardPage previousPage,
                             WizardPage nextPage,
                             Serializable previousPageData)
                      throws WizardException
Template method that gets called after the next page has been determined in the sequence.

Parameters:
previousPage - The previousPage that was displayted
nextPage - WizardPage the next page that is about to be displayed.
previousPageData - Serializable the previously entered data from the last page where the user clicked 'next'.
Returns:
boolean true if you wish for the user to continue. False if the page data needs to be vetoed.
Throws:
WizardException - upon error.

checkAgainstIllegalJump

protected void checkAgainstIllegalJump(int pageIndex)
Checks that there were no illegally jumping forward moves caused by parameter manipulation.

Parameters:
src - WizardPage the wizard page we're checking against.
Throws:
IllegalStateException - if the check fails.

getPageById

public WizardPage getPageById(Serializable s)
Retrieve a page by a given id. The id is different dependong on the implementation.

Parameters:
s - Serializable
Returns:
WizardPage

getAllSteps

protected BranchNode[] getAllSteps()
Retrieve all the steps for the wizard.

Returns:
WizardPage[]

isNeedingRollback

protected boolean isNeedingRollback(WizardPage src)
Checks the backtrace for presence of the given wizard page.

Parameters:
src - WizardPage the source wizard page.
Returns:
boolean true.

rollbackBacktrace

protected void rollbackBacktrace(WizardPage src)
Rolls back the backtrace stack if the src page is already on the stack, indicating that the browser pushed the back button.

Parameters:
src - WizardPage the source of the 'next' event, so we rollback so that it is no longer on the backtrace.

findWizardPageIndex

protected int findWizardPageIndex(WizardPage toFind)
Find the wizard page index so we can define what the next page is.

Parameters:
toFind - the wizard page to find.
Returns:
integer, the index inside wizSteps
Throws:
IllegalStateException - if we're unable to find the page.

getAllData

public Map getAllData()
               throws WizardException
Retrieve all the data for the wizard keyed by page id.

Returns:
Map of WizardPage objects keyed by id.
Throws:
WizardException - upon error

getStepHistory

public List getStepHistory()
                    throws WizardException
Retrieve all Pages in the order that the person has stepped through them.

Returns:
List
Throws:
WizardException - upon retrieval order.

getMainStepHistory

public List getMainStepHistory()
                        throws WizardException
Will return a history of steps without accounting for any of the branching

Returns:
List
Throws:
WizardException

includeInMainStep

protected boolean includeInMainStep(BranchNode node)

equals

public boolean equals(Object parm1)
Override of Object.equals to check field by field. Checks for equality field by field.

Overrides:
equals in class AbstractWizard
Parameters:
parm1 - the object SequentialWizard
Returns:
true if the fields are equal.

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class AbstractWizard
Returns:
a hash code value for this object.

processFinish

public Object processFinish(WizardPage src,
                            Serializable data,
                            Map additonalParams)
                     throws WizardException
Processes the final finish and returns some sort of data that can be whatever is desired.

Specified by:
processFinish in interface Wizard
Overrides:
processFinish in class AbstractWizard
Parameters:
src - WizardPage the source of the event.
data - Serializable the data given during wht wizard post.
additonalParams - anything that the underlying wizard needs. The values are set by the Application Controller.
Returns:
Object: whatever object the wizard returns after processing.
Throws:
WizardException - upon error.

previous

public WizardPage previous()
                    throws WizardException
Backtracks the stack.

Retrieve the first wizard page and initialize any special data for the Wizard.

Specified by:
previous in interface Wizard
Overrides:
previous in class AbstractWizard
Returns:
WizardPage instance.
Throws:
WizardException - upon error.

toString

public String toString()
Override of toString().

Overrides:
toString in class AbstractWizard
Returns:
Wizard Title


Copyright © 2004-2006 Codeguild, Inc.. All Rights Reserved.