From db4943060c9cb89d49921fc94a095873deca8033 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Thu, 27 Mar 2008 11:42:41 +0000 Subject: [PATCH] javadoc --- .../webflow/mvc/FlowHandler.java | 6 ++--- .../webflow/mvc/FlowHandlerAdapter.java | 26 ++++++++++++++++--- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/FlowHandler.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/FlowHandler.java index 5ef78040..78bc0ef0 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/FlowHandler.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/FlowHandler.java @@ -38,8 +38,8 @@ import org.springframework.webflow.core.collection.MutableAttributeMap; public interface FlowHandler { /** - * Returns the id of the flow handled by this handler. Used by a Controller to load the flow definition. - * @return the flow id + * Returns the id of the flow handled by this handler. Used by a Controller to load the flow definition. Optional. + * @return the flow id, or null if the flow id should be determined by the caller */ public String getFlowId(); @@ -47,7 +47,7 @@ public interface FlowHandler { * Creates the flow execution input map to pass to a new instance of the flow being started. Used by a Controller to * launch the flow execution with the correct input. * @param request the current request - * @return the input map + * @return the input map, or null if the contents of the input map should be determined by the caller */ public MutableAttributeMap createExecutionInputMap(HttpServletRequest request); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/FlowHandlerAdapter.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/FlowHandlerAdapter.java index c04af52c..8843b8f6 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/FlowHandlerAdapter.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/FlowHandlerAdapter.java @@ -121,9 +121,10 @@ public class FlowHandlerAdapter extends WebApplicationObjectSupport implements H } } else { try { - MutableAttributeMap input = flowHandler.createExecutionInputMap(request); + String flowId = getFlowId(flowHandler, request); + MutableAttributeMap input = getInputMap(flowHandler, request); ServletExternalContext context = createServletExternalContext(request, response); - FlowExecutionResult result = flowExecutor.launchExecution(flowHandler.getFlowId(), input, context); + FlowExecutionResult result = flowExecutor.launchExecution(flowId, input, context); return handleFlowExecutionResult(result, context, request, response, flowHandler); } catch (FlowException e) { return handleFlowException(e, request, response, flowHandler); @@ -221,7 +222,7 @@ public class FlowHandlerAdapter extends WebApplicationObjectSupport implements H } else { ModelAndView mv = handler.handleExecutionOutcome(result.getEndedOutcome(), result.getEndedOutput(), request, response); - return mv != null ? mv : defaultHandleFlowOutcome(handler.getFlowId(), result.getEndedOutcome(), result + return mv != null ? mv : defaultHandleFlowOutcome(result.getFlowId(), result.getEndedOutcome(), result .getEndedOutput(), request, response); } } else { @@ -241,11 +242,28 @@ public class FlowHandlerAdapter extends WebApplicationObjectSupport implements H private ModelAndView handleFlowException(FlowException e, HttpServletRequest request, HttpServletResponse response, FlowHandler handler) throws IOException { ModelAndView result = handler.handleException(e, request, response); - return result != null ? result : defaultHandleFlowException(handler.getFlowId(), e, request, response); + return result != null ? result : defaultHandleFlowException(getFlowId(handler, request), e, request, response); } public long getLastModified(HttpServletRequest request, Object handler) { return -1; } + private String getFlowId(FlowHandler handler, HttpServletRequest request) { + String flowId = handler.getFlowId(); + if (flowId != null) { + return flowId; + } else { + return urlHandler.getFlowId(request); + } + } + + private MutableAttributeMap getInputMap(FlowHandler handler, HttpServletRequest request) { + MutableAttributeMap input = handler.createExecutionInputMap(request); + if (input != null) { + return input; + } else { + return defaultFlowExecutionInputMap(request); + } + } }