Example usage for org.springframework.web.method.support ModelAndViewContainer isRequestHandled

List of usage examples for org.springframework.web.method.support ModelAndViewContainer isRequestHandled

Introduction

In this page you can find the example usage for org.springframework.web.method.support ModelAndViewContainer isRequestHandled.

Prototype

public boolean isRequestHandled() 

Source Link

Document

Whether the request has been handled fully within the handler.

Usage

From source file:co.paralleluniverse.springframework.web.servlet.mvc.method.annotation.FiberServletInvocableHandlerMethod.java

/**
 * Invokes the method and handles the return value through a registered
 * {@link HandlerMethodReturnValueHandler}.
 *
 * @param webRequest the current request
 * @param mavContainer the ModelAndViewContainer for this request
 * @param providedArgs "given" arguments matched by type, not resolved
 *//*from w  ww.java 2 s  .co  m*/
public final void invokeAndHandle(ServletWebRequest webRequest, ModelAndViewContainer mavContainer,
        Object... providedArgs) throws Exception {

    Object returnValue = invokeForRequest(webRequest, mavContainer, providedArgs);

    setResponseStatus(webRequest);

    if (returnValue == null) {
        if (isRequestNotModified(webRequest) || hasResponseStatus() || mavContainer.isRequestHandled()) {
            mavContainer.setRequestHandled(true);
            return;
        }
    } else if (StringUtils.hasText(this.responseReason)) {
        mavContainer.setRequestHandled(true);
        return;
    }

    mavContainer.setRequestHandled(false);

    try {
        this.returnValueHandlers.handleReturnValue(returnValue, getReturnValueType(returnValue), mavContainer,
                webRequest);
    } catch (Exception ex) {
        if (logger.isTraceEnabled()) {
            logger.trace(getReturnValueHandlingErrorMessage("Error handling return value", returnValue), ex);
        }
        throw ex;
    }
}

From source file:co.paralleluniverse.springframework.web.servlet.mvc.method.annotation.FiberRequestMappingHandlerAdapter.java

private ModelAndView getModelAndView(ModelAndViewContainer mavContainer, ModelFactory modelFactory,
        NativeWebRequest webRequest) throws Exception {
    modelFactory.updateModel(webRequest, mavContainer);
    if (mavContainer.isRequestHandled()) {
        return null;
    }// w w w  . j a va 2 s. c  o m
    ModelMap model = mavContainer.getModel();
    ModelAndView mav = new ModelAndView(mavContainer.getViewName(), model);
    if (!mavContainer.isViewReference()) {
        mav.setView((View) mavContainer.getView());
    }
    if (model instanceof RedirectAttributes) {
        Map<String, ?> flashAttributes = ((RedirectAttributes) model).getFlashAttributes();
        HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
        RequestContextUtils.getOutputFlashMap(request).putAll(flashAttributes);
    }
    return mav;
}

From source file:org.springframework.web.method.annotation.ModelFactory.java

/**
 * Promote model attributes listed as {@code @SessionAttributes} to the session.
 * Add {@link BindingResult} attributes where necessary.
 * @param request the current request/*from ww w . jav  a  2 s  . c  om*/
 * @param container contains the model to update
 * @throws Exception if creating BindingResult attributes fails
 */
public void updateModel(NativeWebRequest request, ModelAndViewContainer container) throws Exception {
    ModelMap defaultModel = container.getDefaultModel();
    if (container.getSessionStatus().isComplete()) {
        this.sessionAttributesHandler.cleanupAttributes(request);
    } else {
        this.sessionAttributesHandler.storeAttributes(request, defaultModel);
    }
    if (!container.isRequestHandled() && container.getModel() == defaultModel) {
        updateBindingResult(request, defaultModel);
    }
}