|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts.action.Action
org.springframework.web.struts.ActionSupport
org.springframework.webflow.executor.struts.FlowAction
public class FlowAction
Point of integration between Struts and Spring Web Flow: a Struts Action that acts a front controller entry point into the web flow system. A single FlowAction may launch any new FlowExecution. In addition, a single Flow Action may signal events in any existing/restored FlowExecutions.
Requests are managed by and delegated to a FlowExecutor
, which this class delegates to using a
FlowRequestHandler
(allowing reuse of common front flow controller logic in other environments). Consult the
JavaDoc of those classes for more information on how requests are processed.
FlowExecutorArgumentHandler.getFlowIdArgumentName()
request parameter indicating the flow definition to
launch.
FlowExecutorArgumentHandler.getFlowExecutionKeyArgumentName()
request parameter identifying the conversation
to participate in.
On each request received by this action, a StrutsExternalContext
object is created as input to the web flow
system. This external source event provides access to the action form, action mapping, and other Struts-specific
constructs.
This class also is aware of the SpringBindingActionForm
adapter, which adapts Spring's data binding
infrastructure (based on POJO binding, a standard Errors interface, and property editor type conversion) to the
Struts action form model. This option gives backend web-tier developers full support for POJO-based binding with
minimal hassel, while still providing consistency to view developers who already have a lot of experience with Struts
for markup and request dispatching.
Below is an example struts-config.xml
configuration for a FlowAction:
<action path="/userRegistration" type="org.springframework.webflow.executor.struts.FlowAction" name="springBindingActionForm" scope="request"> </action>This example maps the logical request URL
/userRegistration.do
as a Flow controller (FlowAction
).
It is expected that flows to launch be provided in a dynamic fashion by the views (allowing this single
FlowAction
to manage any number of flow executions). A Spring binding action form instance is set in
request scope, acting as an adapter enabling POJO-based binding and validation with Spring.
Other notes regarding Struts/Spring Web Flow integration:
ViewStates
and EndStates
are entered are mapped
to physical view templates using standard Struts action forwards (typically global forwards).SpringBindingActionForm
requires no special setup in struts-config.xml
:
simply declare a form bean in request scope of the class
org.springframework.web.struts.SpringBindingActionForm
and use it with your FlowAction.FlowExecutor
instance to be configured. If relying on Spring's
DelegatingActionProxy
(which is recommended), a FlowExecutor reference can simply be injected using standard
Spring dependency injection techniques. If you are not using the proxy-based approach, this class will attempt a root
context lookup on initialization, first querying for a bean of instance FlowExecutor
named
FLOW_EXECUTOR_BEAN_NAME
.FlowExecutorArgumentHandler
used by the FlowAction can
be configured in the root context using a bean of name FLOW_EXECUTOR_ARGUMENT_HANDLER_BEAN_NAME
. If not
explicitly specified it will default to a normal
RequestParameterFlowExecutorArgumentHandler
with standard
configuration.
The benefits here are considerable: developers now have a powerful web flow capability integrated with Struts, with a
consistent-approach to POJO-based binding and validation that addresses the proliferation of ActionForm
classes found in traditional Struts-based apps.
FlowExecutor
,
FlowRequestHandler
,
SpringBindingActionForm
,
DelegatingActionProxy
Field Summary | |
---|---|
protected static java.lang.String |
FLOW_EXECUTOR_ARGUMENT_HANDLER_BEAN_NAME
The flow executor argument handler will be retreived from the application context using this bean name if no argument handler is explicitly set. |
protected static java.lang.String |
FLOW_EXECUTOR_BEAN_NAME
The flow executor will be retreived from the application context using this bean name if no executor is explicitly set. |
Fields inherited from class org.apache.struts.action.Action |
---|
defaultLocale, servlet |
Constructor Summary | |
---|---|
FlowAction()
|
Method Summary | |
---|---|
protected org.apache.struts.action.ActionForward |
createRedirectForward(java.lang.String url,
javax.servlet.http.HttpServletResponse response)
Handles a redirect. |
protected FlowRequestHandler |
createRequestHandler()
Factory method that creates a new helper for processing a request into this flow controller. |
org.apache.struts.action.ActionForward |
execute(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
protected org.apache.struts.action.ActionForward |
findForward(ApplicationView forward,
org.apache.struts.action.ActionMapping mapping)
Find an action forward for given application view. |
FlowExecutorArgumentHandler |
getArgumentHandler()
Returns the flow executor argument handler used by this controller. |
FlowExecutor |
getFlowExecutor()
Returns the flow executor used by this controller. |
protected void |
onInit()
|
void |
setArgumentHandler(FlowExecutorArgumentHandler argumentHandler)
Sets the flow executor argument handler to use. |
void |
setFlowExecutor(FlowExecutor flowExecutor)
Configures the flow executor implementation to use. |
protected org.apache.struts.action.ActionForward |
toActionForward(ResponseInstruction responseInstruction,
org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ExternalContext context)
Return a Struts ActionForward given a ResponseInstruction. |
Methods inherited from class org.springframework.web.struts.ActionSupport |
---|
getMessageSourceAccessor, getServletContext, getTempDir, getWebApplicationContext, initWebApplicationContext, onDestroy, setServlet |
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, saveErrors, saveMessages, saveMessages, saveToken, setLocale |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String FLOW_EXECUTOR_BEAN_NAME
protected static final java.lang.String FLOW_EXECUTOR_ARGUMENT_HANDLER_BEAN_NAME
Constructor Detail |
---|
public FlowAction()
Method Detail |
---|
public FlowExecutor getFlowExecutor()
public void setFlowExecutor(FlowExecutor flowExecutor)
flowExecutor
- the fully configured flow executorpublic FlowExecutorArgumentHandler getArgumentHandler()
public void setArgumentHandler(FlowExecutorArgumentHandler argumentHandler)
argumentHandler
- the fully configured argument handlerprotected void onInit()
onInit
in class org.springframework.web.struts.ActionSupport
public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
execute
in class org.apache.struts.action.Action
java.lang.Exception
protected FlowRequestHandler createRequestHandler()
protected org.apache.struts.action.ActionForward toActionForward(ResponseInstruction responseInstruction, org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ExternalContext context) throws java.lang.Exception
java.lang.Exception
protected org.apache.struts.action.ActionForward createRedirectForward(java.lang.String url, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
url
- the url to redirect toresponse
- the http response
java.lang.Exception
- an excpetion occured processing the redirectHttpServletResponse.sendRedirect(java.lang.String)
protected org.apache.struts.action.ActionForward findForward(ApplicationView forward, org.apache.struts.action.ActionMapping mapping)
forward
- the application view to find a forward formapping
- the action mapping to use
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |