SWF-183
Expose WindowState and PortletMode as native request attributes, portletWindowState and portletMode respectively. This will make them accessible inside flow executions without needing the native request.
This commit is contained in:
@@ -47,6 +47,7 @@ public class FlowHandlerAdapter extends PortletApplicationObjectSupport implemen
|
||||
|
||||
public ModelAndView handleRender(RenderRequest request, RenderResponse response, Object handler) throws Exception {
|
||||
FlowHandler flowHandler = (FlowHandler) handler;
|
||||
populateConveniencePortletProperties(request);
|
||||
PortletSession session = request.getPortletSession(false);
|
||||
if (session != null) {
|
||||
FlowException e = (FlowException) session.getAttribute(ACTION_FLOW_EXCEPTION_ATTRIBUTE);
|
||||
@@ -86,6 +87,7 @@ public class FlowHandlerAdapter extends PortletApplicationObjectSupport implemen
|
||||
}
|
||||
|
||||
public void handleAction(ActionRequest request, ActionResponse response, Object handler) throws Exception {
|
||||
populateConveniencePortletProperties(request);
|
||||
String flowExecutionKey = urlHandler.getFlowExecutionKey(request);
|
||||
PortletExternalContext context = createPortletExternalContext(request, response);
|
||||
try {
|
||||
@@ -102,6 +104,11 @@ public class FlowHandlerAdapter extends PortletApplicationObjectSupport implemen
|
||||
|
||||
// subclassing hooks
|
||||
|
||||
protected void populateConveniencePortletProperties(PortletRequest request) {
|
||||
request.setAttribute("portletMode", request.getPortletMode().toString());
|
||||
request.setAttribute("portletWindowState", request.getWindowState().toString());
|
||||
}
|
||||
|
||||
protected PortletExternalContext createPortletExternalContext(PortletRequest request, PortletResponse response) {
|
||||
return new PortletExternalContext(getPortletContext(), request, response);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,6 @@ import org.springframework.webflow.execution.Event;
|
||||
import org.springframework.webflow.execution.repository.NoSuchFlowExecutionException;
|
||||
import org.springframework.webflow.executor.FlowExecutionResult;
|
||||
import org.springframework.webflow.executor.FlowExecutor;
|
||||
import org.springframework.webflow.mvc.portlet.FlowHandler;
|
||||
import org.springframework.webflow.mvc.portlet.FlowHandlerAdapter;
|
||||
import org.springframework.webflow.test.MockFlowExecutionKey;
|
||||
|
||||
public class FlowHandlerAdapterTests extends TestCase {
|
||||
@@ -209,4 +207,10 @@ public class FlowHandlerAdapterTests extends TestCase {
|
||||
assertEquals("error", mv.getViewName());
|
||||
}
|
||||
|
||||
public void testPopulateConveniencePortletProperties() {
|
||||
controller.populateConveniencePortletProperties(renderRequest);
|
||||
assertEquals(renderRequest.getPortletMode().toString(), renderRequest.getAttribute("portletMode"));
|
||||
assertEquals(renderRequest.getWindowState().toString(), renderRequest.getAttribute("portletWindowState"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user