ModelAndView's "cleared" state gets preserved in case of plain model Map access
This commit is contained in:
parent
eb1631f458
commit
84ea67669a
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -19,6 +19,7 @@ package org.springframework.web.portlet;
|
|||
import java.util.Map;
|
||||
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Holder for both Model and View in the web MVC framework.
|
||||
|
|
@ -50,7 +51,7 @@ public class ModelAndView {
|
|||
/**
|
||||
* Indicates whether or not this instance has been cleared with a call to {@link #clear()}.
|
||||
*/
|
||||
private boolean cleared;
|
||||
private boolean cleared = false;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -266,11 +267,11 @@ public class ModelAndView {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return whether this ModelAndView object is empty
|
||||
* Return whether this ModelAndView object is empty,
|
||||
* i.e. whether it does not hold any view and does not contain a model.
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return (this.view == null && this.model == null);
|
||||
return (this.view == null && CollectionUtils.isEmpty(this.model));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -100,7 +100,7 @@ public class WebRequestHandlerInterceptorAdapter implements HandlerInterceptor {
|
|||
RenderRequest request, RenderResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||
|
||||
this.requestInterceptor.postHandle(new PortletWebRequest(request),
|
||||
(modelAndView != null ? modelAndView.getModelMap() : null));
|
||||
(modelAndView != null && !modelAndView.wasCleared() ? modelAndView.getModelMap() : null));
|
||||
}
|
||||
|
||||
public void afterRenderCompletion(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -19,6 +19,7 @@ package org.springframework.web.servlet;
|
|||
import java.util.Map;
|
||||
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Holder for both Model and View in the web MVC framework.
|
||||
|
|
@ -51,7 +52,7 @@ public class ModelAndView {
|
|||
/**
|
||||
* Indicates whether or not this instance has been cleared with a call to {@link #clear()}.
|
||||
*/
|
||||
private boolean cleared;
|
||||
private boolean cleared = false;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -267,17 +268,17 @@ public class ModelAndView {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return whether this ModelAndView object is empty
|
||||
* Return whether this ModelAndView object is empty,
|
||||
* i.e. whether it does not hold any view and does not contain a model.
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return (this.view == null && this.model == null);
|
||||
return (this.view == null && CollectionUtils.isEmpty(this.model));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this ModelAndView object is empty as a result of a call to {@link #clear}
|
||||
* i.e. whether it does not hold any view and does not contain a model.
|
||||
* Returns <code>false</code> if any additional state was added to the instance
|
||||
* <p>Returns <code>false</code> if any additional state was added to the instance
|
||||
* <strong>after</strong> the call to {@link #clear}.
|
||||
* @see #clear()
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -59,7 +59,7 @@ public class WebRequestHandlerInterceptorAdapter implements HandlerInterceptor {
|
|||
throws Exception {
|
||||
|
||||
this.requestInterceptor.postHandle(new DispatcherServletWebRequest(request),
|
||||
(modelAndView != null ? modelAndView.getModelMap() : null));
|
||||
(modelAndView != null && !modelAndView.wasCleared() ? modelAndView.getModelMap() : null));
|
||||
}
|
||||
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||
|
|
|
|||
Loading…
Reference in New Issue