Expresso Workflow and FormsThe following new features were added to Expresso to both facilitate and encourage a certain approach to developing screen flow logic. This approach expects controller objects to only perform ‘controller’ functions as described in the MVC design pattern.
Expresso Components Listing |
||||||
IntroductionThe following new features were added to Expresso to both facilitate and encourage a certain approach to developing screen flow logic. This approach expects controller objects to only perform ‘controller’ functions as described in the MVC design pattern. This should limit the controller to ‘adapt’ and ‘mediate’ type of actions. Thanks to the Controller class’ support for the HTTP protocol, there should be little need for web applications to provide their own ‘adapting’ code. This is because Expresso provides abstractions such as ControllerRequest and PersistentSession objects that have already done the adapting work between the HTTP and Java worlds. |
|
||||||||||||||||||||
Theory Introduction
Most of the code required in Controller descendant classes should be solely
for the purpose of providing ‘mediation’ logic. This is the logic that
ties components of the application together. The new features that have
been added to the Controller class encourage developers to keep this mediation
logic inside controller objects by providing support for mediation between
state objects. This should help to avoid mediation code finding its way
into state classes.
Prompt states are those which build the contents of a screen using Input, Output, Block and Transition objects. The Controller will add its own transition objects based on the ‘position’ of the prompt state within the controller these are the Next and Previous buttons common in wizards. When errors are generated in a prompt state’s associated handle state, the prompt state will be invoked by default assuming the handle state has not overridden this at runtime. Controller & State FormsThe new features provide for the concept of both a state and controller form. The controller form holds all the data required by the final state to complete the use-case. The state form holds only the data required by the individual states to perform their duties. Controller forms should inherit from com.jcorporate.expresso.core.controller.ControllerForm and state forms should implement the com.jcorporate.expresso.core.controller.StateForm interface.
The state form defines the contract between the controller and the state. A state’s form is specified using the addStatePairing() method as described below. It is populated from the controller form just prior to invoking the state. A new method has been defined within the State class called ‘perform()’. This method replaces the existing run() method and should therefore be overridden to define state logic. This method has an additional parameter of type StateForm. Once the perform() has completed, the updated state form data is put back into the controller form. In a wizard setup, the attributes of the state form would be made up of a subset of the attributes on the controller form - this helps isolate the state from the other states in the controller. In a single screen controller, the state form would be the actual controller form. Workflow The new features to support workflow capabilities revolve around the ability
to direct execution between states and controllers. A new method, enableReturnToSender(),
has been added to the Transition class and special Transition parameters
can also be added to direct traffic.
The preferred approach is to define the flow at Controller Definition time. This keeps the mediation logic in the controller wherever possible. Placing it in the Screen Build time allows for more flexibility while keeping the flow logic outside of the state handlers. The last option allows a state to determine where to route to based on run time considerations that are only known by the state itself (use one of the first two options whenever possible). If flow is defined in more than one of these locations then the following priority is followed: 1) State Run 2) Screen Build 3) Controller Definition. Controller DefinitionState default flowWhen using the new features, a controller’s constructor should no longer call the addState() method. The new addStatePairing(State, State, String) and addFinalState(State) methods should be called instead. Controller Security & Chaining flowThe following two new attributes have been added to the Controller class: controllerChainingTransition and controllerSecurityTransition. Controller Chaining allows an application to specify the controller to be invoked once the current one completes. A controller completes once the final state has run without errors. Controller Security allows an application to specify the controller to be invoked if a user encounters controller authorization failure on a state in the current controller. Both of these new attributes are of type Transition, and if needed would normally be setup in the controller’s constructor. Screen BuildA state normally adds transition objects to its response in order to be displayed as links or buttons on an HTML page. These transition objects can have either the special parameters set or can have the enableReturnToSender() method called before doing this. Enabling the return-to-sender would cause the target controller/state to re-invoke this source state so that it can redisplay the screen to the user. Alternatively the special parameters can be used to route to some other destination. State RunThe State class now has two new attributes of type Transition:
These attributes can be set in the state’s perform() method. Doing so would override any routing that was defined at the Controller Definition or Screen Build times. When a state completes its execution, these two attributes will be used to determine which transition to execute (if any). If the ErrorCollection is not empty then the errorTransition will be used otherwise the successTransition will be executed. This approach is similar to returning an ActionForward in Struts and so state logic should now create transition objects and set the required attributes but not call the transition() method. Rather, the newly created transition objects should be assigned to one of the two new attributes of the State class.. ConclusionFor technical information about how to use workflow, please refer to the
Expresso Developers Guide (EDG) or the Javadocs |
|
Home | Products | Services | Partners | Customers | About Us | Login | Forums | Contact Us |
Copyright © 2002 Jcorporate Ltd. All rights reserved. Copyright Privacy
Last Modified: 07-Oct-02 6:49:58 PM