This commit is contained in:
Keith Donald
2008-03-27 11:42:41 +00:00
parent 7fcb7bc2d0
commit db4943060c
2 changed files with 25 additions and 7 deletions

View File

@@ -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);

View File

@@ -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);
}
}
}