/** * Convenience method that retrieves the {@link #getOutputFlashMap "output" * FlashMap}, updates it with the path and query params of the target URL, * and then saves it using the {@link #getFlashMapManager FlashMapManager}. * @param location the target URL for the redirect * @param request the current request * @param response the current response * @since 5.0 */ public static void saveOutputFlashMap(String location, HttpServletRequest request, HttpServletResponse response) { FlashMap flashMap = getOutputFlashMap(request); if (CollectionUtils.isEmpty(flashMap)) { return; } UriComponents uriComponents = UriComponentsBuilder.fromUriString(location).build(); flashMap.setTargetRequestPath(uriComponents.getPath()); flashMap.addTargetRequestParams(uriComponents.getQueryParams()); FlashMapManager manager = getFlashMapManager(request); Assert.state(manager != null, "No FlashMapManager. Is this a DispatcherServlet handled request?"); manager.saveOutputFlashMap(flashMap, request, response); }
/** * Convenience method that retrieves the {@link #getOutputFlashMap "output" * FlashMap}, updates it with the path and query params of the target URL, * and then saves it using the {@link #getFlashMapManager FlashMapManager}. * @param location the target URL for the redirect * @param request the current request * @param response the current response * @since 5.0 */ public static void saveOutputFlashMap(String location, HttpServletRequest request, HttpServletResponse response) { FlashMap flashMap = getOutputFlashMap(request); if (CollectionUtils.isEmpty(flashMap)) { return; } UriComponents uriComponents = UriComponentsBuilder.fromUriString(location).build(); flashMap.setTargetRequestPath(uriComponents.getPath()); flashMap.addTargetRequestParams(uriComponents.getQueryParams()); FlashMapManager manager = getFlashMapManager(request); Assert.state(manager != null, "No FlashMapManager. Is this a DispatcherServlet handled request?"); manager.saveOutputFlashMap(flashMap, request, response); }
private void saveFlashOutput(String location, HttpServletRequest request, HttpServletResponse response, FlowExecutionResult result) { if ((result == null) || (result.getOutcome() == null) || (result.getOutcome().getOutput().isEmpty())) { return; } AttributeMap<Object> output = result.getOutcome().getOutput(); FlashMapManager flashMapManager = RequestContextUtils.getFlashMapManager(request); if (flashMapManager == null) { return; } UriComponents uriComponents = UriComponentsBuilder.fromUriString(location).build(); FlashMap flashMap = new FlashMap(); flashMap.setTargetRequestPath(uriComponents.getPath()); flashMap.addTargetRequestParams(uriComponents.getQueryParams()); flashMap.putAll(output.asMap()); flashMapManager.saveOutputFlashMap(flashMap, request, response); }
flashMap.addTargetRequestParams(uriComponents.getQueryParams()); flashMap.startExpirationPeriod(30); //30 seconds for redirect request to return FlashMapManager flashMapManager = RequestContextUtils.getFlashMapManager(preq.getRequest()); if (flashMapManager == null) { throw new IllegalStateException("FlashMapManager not found despite output FlashMap has been set");
private void saveFlashOutput(String location, HttpServletRequest request, HttpServletResponse response, FlowExecutionResult result) { if ((result == null) || (result.getOutcome() == null) || (result.getOutcome().getOutput().isEmpty())) { return; } AttributeMap<Object> output = result.getOutcome().getOutput(); FlashMapManager flashMapManager = RequestContextUtils.getFlashMapManager(request); if (flashMapManager == null) { return; } UriComponents uriComponents = UriComponentsBuilder.fromUriString(location).build(); FlashMap flashMap = new FlashMap(); flashMap.setTargetRequestPath(uriComponents.getPath()); flashMap.addTargetRequestParams(uriComponents.getQueryParams()); flashMap.putAll(output.asMap()); flashMapManager.saveOutputFlashMap(flashMap, request, response); }