Java Code Examples for org.springframework.web.servlet.support.RequestContextUtils#getInputFlashMap()

The following examples show how to use org.springframework.web.servlet.support.RequestContextUtils#getInputFlashMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractUrlViewController.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Retrieves the URL path to use for lookup and delegates to
 * {@link #getViewNameForRequest}. Also adds the content of
 * {@link RequestContextUtils#getInputFlashMap} to the model.
 */
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
	String viewName = getViewNameForRequest(request);
	if (logger.isTraceEnabled()) {
		logger.trace("Returning view name '" + viewName + "'");
	}
	return new ModelAndView(viewName, RequestContextUtils.getInputFlashMap(request));
}
 
Example 2
Source File: AbstractUrlViewController.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Retrieves the URL path to use for lookup and delegates to
 * {@link #getViewNameForRequest}. Also adds the content of
 * {@link RequestContextUtils#getInputFlashMap} to the model.
 */
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
	String viewName = getViewNameForRequest(request);
	if (logger.isTraceEnabled()) {
		logger.trace("Returning view name '" + viewName + "'");
	}
	return new ModelAndView(viewName, RequestContextUtils.getInputFlashMap(request));
}
 
Example 3
Source File: AbstractUrlViewController.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retrieves the URL path to use for lookup and delegates to
 * {@link #getViewNameForRequest}. Also adds the content of
 * {@link RequestContextUtils#getInputFlashMap} to the model.
 */
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
	String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
	String viewName = getViewNameForRequest(request);
	if (logger.isDebugEnabled()) {
		logger.debug("Returning view name '" + viewName + "' for lookup path [" + lookupPath + "]");
	}
	return new ModelAndView(viewName, RequestContextUtils.getInputFlashMap(request));
}
 
Example 4
Source File: AbstractUrlViewController.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves the URL path to use for lookup and delegates to
 * {@link #getViewNameForRequest}. Also adds the content of
 * {@link RequestContextUtils#getInputFlashMap} to the model.
 */
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
	String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
	String viewName = getViewNameForRequest(request);
	if (logger.isDebugEnabled()) {
		logger.debug("Returning view name '" + viewName + "' for lookup path [" + lookupPath + "]");
	}
	return new ModelAndView(viewName, RequestContextUtils.getInputFlashMap(request));
}
 
Example 5
Source File: RefreshControllerServiceImpl.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * Handles the return from a multi-value lookup, processing any select line values and invoking the
 * configured view helper service to create the lines for those values in the model collection.
 *
 * <p>There are two supported strategies for returning the selected lines. One, if the lookup view
 * and the caller are within the same application container, Springs input flash map is used. If however,
 * the lookup view is outside the caller, then just a standard request parameter is used.</p>
 *
 * @param form form instance containing the model data
 * @param request http request object being handled
 */
protected void processMultiValueReturn(final UifFormBase form, HttpServletRequest request) {
    final String lookupCollectionId = request.getParameter(UifParameters.LOOKUP_COLLECTION_ID);

    final String lookupCollectionName = request.getParameter(UifParameters.LOOKUP_COLLECTION_NAME);
    if (StringUtils.isBlank(lookupCollectionName)) {
        throw new RuntimeException("Lookup collection name is required for processing multi-value lookup results");
    }

    final String multiValueReturnFields = request.getParameter(UifParameters.MULIT_VALUE_RETURN_FILEDS);
    String selectedLineValuesParam = request.getParameter(UifParameters.SELECTED_LINE_VALUES);

    String flashMapSelectedLineValues = "";
    if (RequestContextUtils.getInputFlashMap(request) != null) {
        flashMapSelectedLineValues = (String) RequestContextUtils.getInputFlashMap(request).get(
                UifParameters.SELECTED_LINE_VALUES);
    }

    if (!StringUtils.isBlank(flashMapSelectedLineValues)) {
        selectedLineValuesParam = flashMapSelectedLineValues;
    }

    final String selectedLineValues = selectedLineValuesParam;

    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            // invoked view helper to populate the collection from lookup results
            ViewLifecycle.getHelper().processMultipleValueLookupResults(form, lookupCollectionId,
                    lookupCollectionName, multiValueReturnFields, selectedLineValues);
        }
    };

    ViewLifecycle.encapsulateLifecycle(form.getView(), form, form.getViewPostMetadata(), null, request, runnable);
}
 
Example 6
Source File: PoemSubmission.java    From tutorials with MIT License 5 votes vote down vote up
@GetMapping("/poem/success")
public String getSuccess(HttpServletRequest request) {
    Map<String, ?> inputFlashMap = RequestContextUtils.getInputFlashMap(request);
    if (inputFlashMap != null) {
        Poem poem = (Poem) inputFlashMap.get("poem");
        return "success";
    } else {
        return "redirect:/poem/submit";
    }
}