/** * Create a new external context wrapping given servlet HTTP request and response and given servlet context. * @param context the servlet context * @param request the http servlet request * @param response the http servlet response */ public ServletExternalContext(ServletContext context, HttpServletRequest request, HttpServletResponse response) { init(context, request, response, new DefaultFlowUrlHandler()); }
/** * Create a new external context wrapping given servlet HTTP request and response and given servlet context. * @param context the servlet context * @param request the http servlet request * @param response the http servlet response * @param flowUrlHandler the flow url handler */ public ServletExternalContext(ServletContext context, HttpServletRequest request, HttpServletResponse response, FlowUrlHandler flowUrlHandler) { init(context, request, response, flowUrlHandler); }
public void requestExternalRedirect(String location) throws IllegalStateException { assertResponseAllowed(); externalRedirectUrl = location; recordResponseComplete(); }
private void init(ServletContext context, HttpServletRequest request, HttpServletResponse response, FlowUrlHandler flowUrlHandler) { this.context = context; this.request = request; this.response = response; this.requestParameterMap = new LocalParameterMap(new HttpServletRequestParameterMap(request)); this.requestMap = new LocalAttributeMap<>(new HttpServletRequestMap(request)); this.sessionMap = new LocalSharedAttributeMap<>(new HttpSessionMap(request)); this.applicationMap = new LocalSharedAttributeMap<>(new HttpServletContextMap(context)); this.flowUrlHandler = flowUrlHandler; }
private boolean isRedirectRequested() { return getFlowExecutionRedirectRequested() || getFlowDefinitionRedirectRequested() || getExternalRedirectRequested(); }
private void sendFlowExecutionRedirect(FlowExecutionResult result, ServletExternalContext context, HttpServletRequest request, HttpServletResponse response) throws IOException { String url = flowUrlHandler.createFlowExecutionUrl(result.getFlowId(), result.getPausedKey(), request); if (logger.isDebugEnabled()) { logger.debug("Sending flow execution redirect to '" + url + "'"); } if (context.isAjaxRequest()) { ajaxHandler.sendAjaxRedirect(url, request, response, context.getRedirectInPopup()); } else { sendRedirect(url, request, response); } }
public void afterPropertiesSet() throws Exception { Assert.notNull(flowExecutor, "The FlowExecutor to execute flows is required"); if (flowUrlHandler == null) { flowUrlHandler = new DefaultFlowUrlHandler(); } if (ajaxHandler == null) { ajaxHandler = new DefaultAjaxHandler(); } }
/** * Creates the servlet external context for the current HTTP servlet request. * @param request the current request * @param response the current response */ protected ServletExternalContext createServletExternalContext(HttpServletRequest request, HttpServletResponse response) { ServletExternalContext context = new MvcExternalContext(getServletContext(), request, response, flowUrlHandler); context.setAjaxRequest(ajaxHandler.isAjaxRequest(request, response)); return context; }
public final void sendAjaxRedirect(String targetUrl, HttpServletRequest request, HttpServletResponse response, boolean popup) throws IOException { if (isAjaxRequestInternal(request, response)) { sendAjaxRedirectInternal(targetUrl, request, response, popup); } if (delegate != null) { delegate.sendAjaxRedirect(targetUrl, request, response, popup); } }
public SharedAttributeMap<Object> getGlobalSessionMap() { return getSessionMap(); }
public final boolean isAjaxRequest(HttpServletRequest request, HttpServletResponse response) { if (isAjaxRequestInternal(request, response)) { return true; } if (delegate != null) { return delegate.isAjaxRequest(request, response); } return false; }
protected void removeAttribute(String key) { HttpSession session = getSession(); if (session != null) { session.removeAttribute(key); } }
protected void initServletContext(ServletContext servletContext) { Assert.notNull(flowRegistry, "The FlowRegistry to query when mapping requests is required"); if (flowUrlHandler == null) { flowUrlHandler = new DefaultFlowUrlHandler(); } }
/** * The default algorithm to determine the id of the flow to launch from the current request. Only called if * {@link FlowHandler#getFlowId()} returns null. This implementation delegates to the configured * {@link FlowUrlHandler#getFlowId(HttpServletRequest)}. Subclasses may override. * @param request the current request */ protected String defaultGetFlowId(HttpServletRequest request) { return flowUrlHandler.getFlowId(request); }
/** * Creates a new flow controller. * @see #setFlowExecutor(FlowExecutor) * @see #setFlowUrlHandler(FlowUrlHandler) * @see #setAjaxHandler(AjaxHandler) * @see #setFlowHandlerAdapter(FlowHandlerAdapter) * @see #afterPropertiesSet() */ public FlowController() { flowHandlerAdapter = new FlowHandlerAdapter(); flowHandlerAdapter.setFlowUrlHandler(new FilenameFlowUrlHandler()); }
public void requestRedirectInPopup() throws IllegalStateException { if (isRedirectRequested()) { redirectInPopup = true; } else { throw new IllegalStateException( "Only call requestRedirectInPopup after a redirect has been requested by calling requestFlowExecutionRedirect, requestFlowDefinitionRedirect, or requestExternalRedirect"); } }
public static String extractFilenameFromUrlPath(String urlPath) { String filename = extractFullFilenameFromUrlPath(urlPath); int dotIndex = filename.lastIndexOf('.'); if (dotIndex != -1) { filename = filename.substring(0, dotIndex); } return filename; }
public void requestFlowExecutionRedirect() throws IllegalStateException { assertResponseAllowed(); flowExecutionRedirectRequested = true; recordResponseComplete(); }