From 544f37b13914eec3d9f8bf4382efcfb314d51e88 Mon Sep 17 00:00:00 2001 From: Burt Beckwith Date: Fri, 26 Jul 2013 19:44:06 -0400 Subject: [PATCH] GRAILS-8917 if nothing is returned from a controller action, use an empty model, not the properties of the controller instance --- .../mvc/AbstractGrailsControllerHelper.java | 19 +------- .../servlet/mvc/GrailsControllerBeanMap.java | 44 ------------------- 2 files changed, 2 insertions(+), 61 deletions(-) delete mode 100644 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/GrailsControllerBeanMap.java diff --git a/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/AbstractGrailsControllerHelper.java b/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/AbstractGrailsControllerHelper.java index 141f5862fea..eb4380cee15 100644 --- a/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/AbstractGrailsControllerHelper.java +++ b/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/AbstractGrailsControllerHelper.java @@ -384,15 +384,7 @@ public ModelAndView handleActionResponse(GroovyObject controller, Object returnV if (viewNameBlank) { return null; } - - Map model; - if (!chainModel.isEmpty()) { - model = new CompositeMap(chainModel, new GrailsControllerBeanMap(controller)); - } - else { - model = new GrailsControllerBeanMap(controller); - } - return new ModelAndView(viewName, model); + return new ModelAndView(viewName, chainModel); } if (returnValue instanceof Map) { @@ -430,14 +422,7 @@ public ModelAndView handleActionResponse(GroovyObject controller, Object returnV return modelAndView; } - Map model; - if (!chainModel.isEmpty()) { - model = new CompositeMap(chainModel, new GrailsControllerBeanMap(controller)); - } - else { - model = new GrailsControllerBeanMap(controller); - } - return new ModelAndView(viewName, model); + return new ModelAndView(viewName, chainModel); } @SuppressWarnings("rawtypes") diff --git a/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/GrailsControllerBeanMap.java b/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/GrailsControllerBeanMap.java deleted file mode 100644 index b5e92b7011e..00000000000 --- a/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/GrailsControllerBeanMap.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2011 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.codehaus.groovy.grails.web.servlet.mvc; - -import grails.web.Action; - -import java.lang.reflect.Method; - -import org.apache.commons.beanutils.BeanMap; - -/** - * Filter action getters. - * - * @author Stephane Maldini - * @since 2.0 - */ -public class GrailsControllerBeanMap extends BeanMap { - - public GrailsControllerBeanMap(Object bean) { - super(bean); - } - - @Override - public Object get(Object name) { - Method method = getReadMethod(name); - if (method.getAnnotation(Action.class) == null) { - return super.get(name); - } - return null; - } -}