com.sri.emo.wizard.expressoimpl
Class WizardController

java.lang.Object
  extended by org.apache.struts.action.Action
      extended by com.jcorporate.expresso.core.controller.Controller
          extended by com.jcorporate.expresso.core.controller.DBController
              extended by com.sri.common.controller.AbstractDBController
                  extended by com.sri.common.controller.AbstractComponentController
                      extended by com.sri.emo.wizard.expressoimpl.WizardController
All Implemented Interfaces:
ComponentServiceLocator, Serializable
Direct Known Subclasses:
CompletionWizardAction, CreationWizardAction, WizardAction

public class WizardController
extends AbstractComponentController

Wizard Controller is basically a thin wrapper over the Wizard domain model which does the actual thinking. The WizardController may be overridden in the case of custom onFinish() behavior.

Author:
Michael Rimov
See Also:
Serialized Form

Field Summary
static String CANCEL_STATE
          Cancel State.
static String CURRENT_PAGE_NUM
          Current page number constant.
static String DISPLAY_STATE
          Display Page State.
static String FINISH_REQUEST
          Parameter for Wizard's finish to get the ExpressoRequest object.
static String FINISH_RESPONSE
          Parameter for the Wizard's finish method to get the ExpressoResponse object.
static String FINISH_STATE
          Finish State.
static String NEXT_STATE
          Next State constant.
static String PREVIOUS_STATE
          Previous State.
static String REQUEST_ID
          Key for the current wizard in the request.
protected static String SESSION_STATE_KEY_PREFIX
          Key for session state for the Wizard.
static String STATE_BEGIN
          Start state constant.
static String STATE_JUMP_BACKWARDS
          State name to allow jumping backwards.
static String TOTAL_PAGES
          Total Pages constant.
static String WIZ_DATA_ID
          Constant for what data is sent us.
static String WIZ_PAGE_PARAMETER
          Current Page ID Parameter name.
static String WIZ_PARAMETER_ID
          Constant for the id of the EMO Wizard that is being executed.
static String WIZ_RESULT_ID
          Where the wizard is stored in the request context when finish() is called.
 
Fields inherited from class com.sri.common.controller.AbstractComponentController
REQUEST_CONTAINER
 
Fields inherited from class com.sri.common.controller.AbstractDBController
COLUMN, COMMON_FOOTER_HANDLER, COMMON_HEADER_HANDLER, DELIMIT, EDIT_GROUP_DISPLAY, EMBEDDED_MODE, FOOTER, MAX_CHARS_OUTPUT, MAX_TEXTAREA_LENGTH, MULTIPLE_TEXTAREA_NUM_LINES, ROW, ROW_BLOCK, SESSION_CONTAINER, SINGLE_TEXTAREA_NUM_LINES, TEXTAREA_NUM_COLS, WARNING_LIST
 
Fields inherited from class com.jcorporate.expresso.core.controller.DBController
CACHE_NAME
 
Fields inherited from class com.jcorporate.expresso.core.controller.Controller
CONTROLLER_PARAM_KEY, CTL_SUCC_CTL, CTL_SUCC_STATE, CTL_SUCC_TRAN, mLog, NEWSTATE_EXCEPTION_KEY, ORIGINAL_URL_KEY, REQUEST_KEY, RESPONSE_KEY, RETURN_TO_SENDER_TRAN, STATE_ERR_CTL, STATE_ERR_STATE, STATE_ERR_TRAN, STATE_PARAM_KEY, STATE_SUCC_CTL, STATE_SUCC_STATE, STATE_SUCC_TRAN
 
Fields inherited from class org.apache.struts.action.Action
defaultLocale, servlet
 
Constructor Summary
WizardController()
          Generic wizard controller.
 
Method Summary
protected  void addOnFinishWizardParameters(ExpressoRequest request, ExpressoResponse response, Map parameterMap)
           
protected  void addPageNumberForSequentialWizards(Wizard wiz, ExpressoResponse response)
           
protected  void addWizardInput(ExpressoResponse response, Wizard wiz, PageMetadata wp)
          Adds the wizard page input.
protected  void afterFinishState(ExpressoRequest request, ExpressoResponse response)
          Template method.
protected  Serializable extractPostedWizardData(ExpressoRequest request)
          Template Method, override in your derived classes if desired.
protected  Transition getCancelTransition()
          Location for transition on cancel instances.
 WizardPage getCurrentPage(ExpressoRequest request, Wizard currentWizard)
          Retrieves the current page as set in the displayed page.
 Wizard getCurrentWizard(ExpressoRequest request)
          Retrieves the current wizard from session.
protected  WizardMementoConverter getMementoConverter()
          Template Method.
protected  String getSessionKey(String dataContext, Serializable wizardId)
          Retrieve where a particular wizard is stored in the session.
 String getTitle()
          Return the title of this Controller.
protected  void handleNoEntryErrorInPage(ExpressoRequest request, ExpressoResponse response)
          Method that handles no-data entry if pages that should have occurred.
protected  boolean hasNoDataEntryAndShould(Object data, WizardPage currentPage)
          Function that allows for consistent checking for whether data was entered.
protected  Wizard newWizard(ExpressoRequest request)
          Create a new wizard and store it to session.
protected  void releaseWizard(ExpressoRequest request, Wizard wiz)
          Removes the wizard resources from the session.
protected  void runBeginState(ExpressoRequest request, ExpressoResponse response)
          Runs the begin state.
protected  void runCancelState(ExpressoRequest request, ExpressoResponse response)
          Runs the cancel state.
protected  void runDisplayState(ExpressoRequest request, ExpressoResponse response)
          Displays the result of the wizard.
protected  void runFinishState(ExpressoRequest request, ExpressoResponse response)
          Run the finish state.
protected  void runJumpBackwardsState(ExpressoRequest request, ExpressoResponse response)
          Runs the state that jumps the wizard backwards to some sort of previous page.
protected  void runNextState(ExpressoRequest request, ExpressoResponse response)
          Runs the next state.
protected  void runPreviousState(ExpressoRequest request, ExpressoResponse response)
          Runs the begin state.
protected  void storeWizInSession(ExpressoRequest request, Wizard toStore, Integer wizId)
          Stores a new wizard to session.
 
Methods inherited from class com.sri.common.controller.AbstractComponentController
addStateHandler, initializeControllerContainer, locate, locator, newExpressoState, postPerform, prePerform
 
Methods inherited from class com.sri.common.controller.AbstractDBController
addEmbeddedParameter, addWarning, addWarningList, getActionForwarding, getCheckbox, getPermsTrans, getPrettyXML, getTextArea, getTextArea, getWarningList, isEmbeddedMode, isValidAndPopulated, outputXML, populateDBObject, stateAllowed, str, strTrunc, trimAllTextFields
 
Methods inherited from class com.jcorporate.expresso.core.controller.DBController
getString, isAllowed
 
Methods inherited from class com.jcorporate.expresso.core.controller.Controller
addFinalState, addPromptTransitions, addRegDomainParamtoSession, addRequestedURLtoSession, addState, addStatePairing, endTimer, execute, findControllerForm, generateToken, getActionForward, getControllerChainingTransition, getControllerSecurityTransition, getFinalState, getInitialState, getLogger, getParamValues, getRequestURL, getSchema, getSchemaHierarchy, getSchemaInstance, getSchemaStack, getState, getStates, getString, getString, handleException, instantiate, isFinalState, isHandleState, isPromptState, isTokenValid, loadStateForm, newState, nextHandleState, nextPromptState, populateStateForm, postPerform, prePerform, previousPromptState, processRequestTransitions, processTransitions, redirectRequest, redirectRequest, remapFromExtension, resetToken, saveToken, setControllerChainingTransition, setControllerSecurityTransition, setCurrentState, setInitialState, setSchema, setSchema, setupDefaultValues, setupReturnToSender, setupSubclassLog, transition, transition, transition, unloadStateForm
 
Methods inherited from class org.apache.struts.action.Action
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_BEGIN

public static final String STATE_BEGIN
Start state constant.

See Also:
Constant Field Values

NEXT_STATE

public static final String NEXT_STATE
Next State constant.

See Also:
Constant Field Values

FINISH_STATE

public static final String FINISH_STATE
Finish State.

See Also:
Constant Field Values

CANCEL_STATE

public static final String CANCEL_STATE
Cancel State.

See Also:
Constant Field Values

DISPLAY_STATE

public static final String DISPLAY_STATE
Display Page State.

See Also:
Constant Field Values

PREVIOUS_STATE

public static final String PREVIOUS_STATE
Previous State.

See Also:
Constant Field Values

STATE_JUMP_BACKWARDS

public static final String STATE_JUMP_BACKWARDS
State name to allow jumping backwards.

See Also:
Constant Field Values

SESSION_STATE_KEY_PREFIX

protected static final String SESSION_STATE_KEY_PREFIX
Key for session state for the Wizard. [More than one wizard is possible in a session since they are keyed by wizard id.


REQUEST_ID

public static final String REQUEST_ID
Key for the current wizard in the request.

See Also:
Constant Field Values

WIZ_PARAMETER_ID

public static final String WIZ_PARAMETER_ID
Constant for the id of the EMO Wizard that is being executed. Used in transitions inside the wizard.

See Also:
Constant Field Values

WIZ_DATA_ID

public static final String WIZ_DATA_ID
Constant for what data is sent us.

See Also:
Constant Field Values

WIZ_RESULT_ID

public static final String WIZ_RESULT_ID
Where the wizard is stored in the request context when finish() is called.

See Also:
Constant Field Values

FINISH_REQUEST

public static final String FINISH_REQUEST
Parameter for Wizard's finish to get the ExpressoRequest object.

See Also:
Constant Field Values

FINISH_RESPONSE

public static final String FINISH_RESPONSE
Parameter for the Wizard's finish method to get the ExpressoResponse object.

See Also:
Constant Field Values

WIZ_PAGE_PARAMETER

public static final String WIZ_PAGE_PARAMETER
Current Page ID Parameter name.

See Also:
Constant Field Values

CURRENT_PAGE_NUM

public static final String CURRENT_PAGE_NUM
Current page number constant.

See Also:
Constant Field Values

TOTAL_PAGES

public static final String TOTAL_PAGES
Total Pages constant.

See Also:
Constant Field Values
Constructor Detail

WizardController

public WizardController()
Generic wizard controller.

Method Detail

getTitle

public String getTitle()
Return the title of this Controller.

Overrides:
getTitle in class Controller
Returns:
java.lang.String The Title of the controller

getCancelTransition

protected Transition getCancelTransition()
Location for transition on cancel instances. Override in custom controllers to have your own capabilities.

Returns:
Transition instance.

getSessionKey

protected String getSessionKey(String dataContext,
                               Serializable wizardId)
Retrieve where a particular wizard is stored in the session.

Parameters:
wizardId - the current id of the wizard.
dataContext - the datacontext for the wizard.
Returns:
String in the session of the Wizard.

getCurrentWizard

public Wizard getCurrentWizard(ExpressoRequest request)
                        throws ControllerException
Retrieves the current wizard from session.

Parameters:
request - the current controller request.
Returns:
Wizard Instance
Throws:
ControllerException - if unable to query the session.

getCurrentPage

public WizardPage getCurrentPage(ExpressoRequest request,
                                 Wizard currentWizard)
                          throws ControllerException
Retrieves the current page as set in the displayed page.

Parameters:
request - ExpressoRequest the controller request object.
currentWizard - Wizard the current wizard.
Returns:
WizardPage the current wizard page as defined by the hidden parameters on the form.
Throws:
ControllerException - upon error.

storeWizInSession

protected void storeWizInSession(ExpressoRequest request,
                                 Wizard toStore,
                                 Integer wizId)
                          throws ControllerException
Stores a new wizard to session.

Parameters:
request - the ExpressoRequest object
toStore - the wizard to store.
wizId - the integer id of the wizard.
Throws:
ControllerException - upon session related error.

getMementoConverter

protected WizardMementoConverter getMementoConverter()
Template Method. Retrieves/Constructs the WizardMementoConverter appropriate for the current run.

Returns:
WizardMementoConverter or null if none is defined.

newWizard

protected Wizard newWizard(ExpressoRequest request)
                    throws WizardException,
                           ControllerException
Create a new wizard and store it to session.

Parameters:
request - the ExpressoRequest object
Returns:
Wizard instance
Throws:
WizardException - upon wizard error
ControllerException - upon expresso controller related error.

runBeginState

protected void runBeginState(ExpressoRequest request,
                             ExpressoResponse response)
                      throws ControllerException,
                             NonHandleableException
Runs the begin state.

Parameters:
request - the ExpressoRequest object
response - the ExpressoResponse object.
Throws:
ControllerException - upon error
NonHandleableException - upon fatal error

runCancelState

protected void runCancelState(ExpressoRequest request,
                              ExpressoResponse response)
                       throws ControllerException,
                              NonHandleableException
Runs the cancel state.

Parameters:
request - the ExpressoRequest object
response - the ExpressoResponse object.
Throws:
ControllerException - upon error
NonHandleableException - upon fatal error

runDisplayState

protected void runDisplayState(ExpressoRequest request,
                               ExpressoResponse response)
                        throws ControllerException,
                               NonHandleableException
Displays the result of the wizard. This particular implementation puts the wizard in the request context under the parameter name of REQUEST_ID. and if the wizard metadata is using expresso links, then it dumps the resulting Transitions into the ExpressoResponse object. [Although JSTL can certainly get the links directly from the REQUEST_ID object's metadata: so choose your style.

Parameters:
request - the ExpressoRequest object
response - the ExpressoResponse object.
Throws:
ControllerException - upon error
NonHandleableException - upon fatal error

runFinishState

protected void runFinishState(ExpressoRequest request,
                              ExpressoResponse response)
                       throws ControllerException,
                              NonHandleableException
Run the finish state.

Parameters:
request - the ExpressoRequest object
response - the ExpressoResponse object.
Throws:
ControllerException - upon error
NonHandleableException - upon fatal error

addOnFinishWizardParameters

protected void addOnFinishWizardParameters(ExpressoRequest request,
                                           ExpressoResponse response,
                                           Map parameterMap)

afterFinishState

protected void afterFinishState(ExpressoRequest request,
                                ExpressoResponse response)
                         throws ControllerException
Template method. Once the wizard is released and processing is finished what do we do?

Parameters:
request - ExpressoRequest Expresso Request object
response - ExpressoResponse ExpressoResponse object
Throws:
ControllerException - upon errors.

releaseWizard

protected void releaseWizard(ExpressoRequest request,
                             Wizard wiz)
                      throws ControllerException,
                             WizardException
Removes the wizard resources from the session.

Parameters:
request - ExpressoRequest the ExpressoRequest object.
wiz - Wizard the Wizard to release.
Throws:
ControllerException - upon session removal error.
WizardException - upon wizard destruction error.

runNextState

protected void runNextState(ExpressoRequest request,
                            ExpressoResponse response)
                     throws ControllerException,
                            NonHandleableException
Runs the next state. This fucntion checks for input and transitions to the display state after invoking the wizard's 'next' function if there were not errors.

Parameters:
request - the ExpressoRequest object
response - the ExpressoResponse object.
Throws:
ControllerException - upon error
NonHandleableException - upon fatal error

extractPostedWizardData

protected Serializable extractPostedWizardData(ExpressoRequest request)
Template Method, override in your derived classes if desired. No matter what, it tries to extract WIZ_DATA_ID. Then It appends _1, _2, _3, etc until it doesn't find any new parameters. If it finds more than one value it returns a Collection, if not, it will return a string. Derived classes, of course, may return other collections depending on the wizard.

Parameters:
request - ExpressoRequest
Returns:
Serializable may be null if the data is not found or incomplete.

handleNoEntryErrorInPage

protected void handleNoEntryErrorInPage(ExpressoRequest request,
                                        ExpressoResponse response)
                                 throws NonHandleableException,
                                        ControllerException
Method that handles no-data entry if pages that should have occurred.

Parameters:
request - ExpressoRequest
response - ExpressoResponse
Throws:
NonHandleableException - upon transition error.
ControllerException - upon error in substate (Usually Display)

hasNoDataEntryAndShould

protected boolean hasNoDataEntryAndShould(Object data,
                                          WizardPage currentPage)
Function that allows for consistent checking for whether data was entered. In this case it checks for null values, zero length strings, or zero size collections.

Parameters:
data - String
currentPage - WizardPage
Returns:
boolean

runPreviousState

protected void runPreviousState(ExpressoRequest request,
                                ExpressoResponse response)
                         throws ControllerException,
                                WizardException
Runs the begin state.

Parameters:
request - the ExpressoRequest object
response - the ExpressoResponse object.
Throws:
ControllerException - upon error
NonHandleableException - upon fatal error
WizardException

runJumpBackwardsState

protected void runJumpBackwardsState(ExpressoRequest request,
                                     ExpressoResponse response)
                              throws ControllerException
Runs the state that jumps the wizard backwards to some sort of previous page.

Parameters:
request - the ExpressoRequest object
response - the ExpressoResponse object.
Throws:
ControllerException - upon error

addWizardInput

protected void addWizardInput(ExpressoResponse response,
                              Wizard wiz,
                              PageMetadata wp)
                       throws ControllerException
Adds the wizard page input. Template method to allow overriding based on

Parameters:
response - ExpressoResponse
wiz - Wizard
wp - PageMetadata
Throws:
ControllerException

addPageNumberForSequentialWizards

protected void addPageNumberForSequentialWizards(Wizard wiz,
                                                 ExpressoResponse response)
                                          throws ControllerException
Throws:
ControllerException


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