From 277f3925a103ab4463614d338885100f629399ab Mon Sep 17 00:00:00 2001 From: Erwin Vervaet Date: Tue, 3 Apr 2007 14:54:43 +0000 Subject: [PATCH] Simplified render phase logic. --- .../executor/mvc/PortletFlowController.java | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/executor/mvc/PortletFlowController.java b/spring-webflow/src/main/java/org/springframework/webflow/executor/mvc/PortletFlowController.java index 0f8b9ee1..fc41b3b6 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/executor/mvc/PortletFlowController.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/executor/mvc/PortletFlowController.java @@ -157,35 +157,29 @@ public class PortletFlowController extends AbstractController implements Initial protected ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws Exception { PortletExternalContext context = new PortletExternalContext(getPortletContext(), request, response); - if (argumentHandler.isFlowExecutionKeyPresent(context)) { - // this is a request to render an active flow execution -- extract its key - String flowExecutionKey = argumentHandler.extractFlowExecutionKey(context); - // look for a cached response instruction in the session put there - // by the action request phase as part of an "active view" forward - ResponseInstruction responseInstruction = extractActionResponseInstruction(request); - if (responseInstruction == null) { - // no response instruction found, simply refresh the current - // view state of the flow execution (happens when the "refresh" browser button is clicked) + + // look for a cached response instruction in the session put there + // by the action request phase + // the response instruction could be an "active application view" rendered + // from a view-state or a "confirmation view" rendered by an end-state + ResponseInstruction responseInstruction = extractActionResponseInstruction(request); + if (responseInstruction != null) { + // found: convert the cached response instruction to model and view for rendering + return toModelAndView(responseInstruction); + } + else { + if (argumentHandler.isFlowExecutionKeyPresent(context)) { + // this is a request to render an active flow execution -- extract its key + String flowExecutionKey = argumentHandler.extractFlowExecutionKey(context); + // simply refresh the current view state of the flow execution (happens + // when the "refresh" browser button is clicked) return toModelAndView(flowExecutor.refresh(flowExecutionKey, context)); } else { - // found: convert the cached response instruction to model and view for rendering - return toModelAndView(responseInstruction); - } - } - else { - // this is either a "launch" flow request or a "confirmation view" render request - // first look for the cached "confirmation view" response instruction - ResponseInstruction responseInstruction = extractActionResponseInstruction(request); - if (responseInstruction == null) { - // no response instruction found in session - launch a new flow execution + // launch a new flow execution String flowId = argumentHandler.extractFlowId(context); return toModelAndView(flowExecutor.launch(flowId, context)); } - else { - // found: convert the cached confirmation response instruction to model and view for rendering - return toModelAndView(responseInstruction); - } } } @@ -252,6 +246,11 @@ public class PortletFlowController extends AbstractController implements Initial * Expose given response instruction to the render phase by putting it in the session. */ private void exposeToRenderPhase(ResponseInstruction responseInstruction, ActionRequest request) { + // there are 2 reasons why we need to put the ResponseInstruction in the session + // and we can't just rely on flow execution 'refresh' during the portlet render phase: + // 1 - a ResponseInstruction rendered from an end-state cannot be refreshed + // ("confirmation view") + // 2 - to make the initial contents of request scope available to the view PortletSession session = request.getPortletSession(false); Assert.notNull(session, "A PortletSession is required"); session.setAttribute(RESPONSE_INSTRUCTION_SESSION_ATTRIBUTE, responseInstruction);