Tutorials to .com

Tutorials to .com » Jsp » Xml » Spring WebFlow: 2 (WebFlow of key components)

Spring WebFlow: 2 (WebFlow of key components)

Print View , by: iSee ,Total views: 13 ,Word Count: 783 ,Date: Mon, 20 Apr 2009 Time: 8:50 PM

WebFlow core components <br> <br> a Spring WebFlow application contains one or more processes, each process typically includes the status of implementation of Action action (ActionStates), show the state (ViewStates), Jump moves (Transitions).

Process <br> <br> a pre-defined process is a good collection of user interaction behavior, expressed as a state and display the status of action consisting of trees, the state of contact between the Jump.

The following is a registered login webflow example, contains a number of typical components, such as loginForm, ActionState, transition. These elements through a xml file description:

<? xml version = "1.0" encoding = "UTF-8"?>

<! DOCTYPE webflow PUBLIC "- / / SPRING / / DTD WEBFLOW / / EN"
<webflow id="LoginSequence" start-state="loginForm">

<action-state id="loginForm">
<action bean="loginFormAction"/>
<transition on="success" to="formView"/>
</ action-state>
<view-state id="formView" view="enterCredentials">
<transition on="submit" to="bindAndValidateForm"/>
</ view-state>
<end-state id="successView" view="displayMain"/>

LoginForm the beginning of this process in order to "successView" end (modified page "displayMain" components. The process can be configured through the xml document, or a sub-category AbstractFlowBuilder.

State action (ActionStates)

ActionStates user events or other incident response. ActionStates itself can also contain other executable Action and transition. The following code to configure the "loginForm" this ActionState.

<action-state id="loginForm">
<action bean="loginFormAction"/>
<transition on="success" to="formView"/>
</ action-state>

Action (Actions)

Action is ActionState can connect, reuse, called the smallest unit of a statement. Action inherited from AbstractAction class, such a method doExecuteAction. The parameters of this method: RequestContext, WebFlow (which encapsulates all the relevant data flow). LoginForm action status Spring assembly through an automatic movement LoginFormAction call characteristics. doExecute

Action method is automatically called, at the same time prepared to deal with some of the registry, such as pre-load operation.

public LoginFormAction extends AbstractAction (

protected Event doExecuteAction (RequestContext context)
throws Exception (
/ / perform some login specific setup operations

) / / end method

) / / end class

Shows the state (ViewState)

ViewState initialize the display components (jsp, tile, etc.) of the modified operation. ViewState following is the configuration of a code <view-state id="formView" view="enterCredentials">
<transition on="submit" to="bindAndValidateForm"/>
</ view-state>

When ActionState from the loginForm returns a "success", this will be called ViewState. It modified "enterCredentials" display components (can be a common struts forward).

Jump (Transition)

And usually the same as the state machine, WebFlow defines Jump between state and state action. These Jump struts action is very similar to the ActionForward. The same state is responsible for connecting the two.

Follow-up action (Continuation)

Follow-up action (Continuation) allows you to rollback and restart the program execution process - from the perspective of the implementation process is a reverse process timely. Continuation of concepts from the first programming language, but it has never been used as the java , VB, c + + such mainstream programming languages. WebFlow creatively to achieve a continuation. as a result of continuation can be used to build a lasting and heavy flow of any state, to provide to you great freedom.

Java and XML Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.