KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > webflow > engine > DecisionState


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.springframework.webflow.engine;
17
18 import org.springframework.webflow.execution.FlowExecutionException;
19 import org.springframework.webflow.execution.RequestContext;
20 import org.springframework.webflow.execution.ViewSelection;
21
22 /**
23  * A simple transitionable state that when entered will execute the first
24  * transition whose matching criteria evaluates to <code>true</code> in the
25  * {@link RequestContext context} of the current request.
26  * <p>
27  * A decision state is a convenient, simple way to encapsulate reusable state
28  * transition logic in one place.
29  *
30  * @author Keith Donald
31  */

32 public class DecisionState extends TransitionableState {
33
34     /**
35      * Creates a new decision state.
36      * @param flow the owning flow
37      * @param stateId the state identifier (must be unique to the flow)
38      * @throws IllegalArgumentException when this state cannot be added to given
39      * flow, e.g. because the id is not unique
40      */

41     public DecisionState(Flow flow, String JavaDoc stateId) throws IllegalArgumentException JavaDoc {
42         super(flow, stateId);
43     }
44
45     /**
46      * Specialization of State's <code>doEnter</code> template method that
47      * executes behaviour specific to this state type in polymorphic fashion.
48      * <p>
49      * Simply looks up the first transition that matches the state of the
50      * context and executes it.
51      * @param context the control context for the currently executing flow, used
52      * by this state to manipulate the flow execution
53      * @return a view selection containing model and view information needed to
54      * render the results of the state execution
55      * @throws FlowExecutionException if an exception occurs in this state
56      */

57     protected ViewSelection doEnter(RequestControlContext context) throws FlowExecutionException {
58         return getRequiredTransition(context).execute(this, context);
59     }
60 }
Popular Tags