diff --git a/build.gradle b/build.gradle index a653379dd73..0185c5af1de 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ ext { commonsCollectionsVersion = "3.2.1" commonsIOVersion = "2.1" commonsLangVersion = "2.6" - datastoreVersion = "1.0.7.RELEASE" + datastoreVersion = "1.0.9.RELEASE" gantVersion = "1.9.6" gdocEngineVersion = "1.0.1" groovyVersion = "1.8.6" diff --git a/grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/GrailsCoreDependencies.java b/grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/GrailsCoreDependencies.java index 50bf0c1a967..1c3be841469 100644 --- a/grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/GrailsCoreDependencies.java +++ b/grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/GrailsCoreDependencies.java @@ -192,7 +192,7 @@ public Object doCall() { }; registerDependencies(dependencyManager, compileTimeDependenciesMethod, commonsExcludingLoggingAndXmlApis, "commons-logging", "xml-apis", "commons-digester"); - String datastoreMappingVersion = "1.0.7.RELEASE"; + String datastoreMappingVersion = "1.0.9.RELEASE"; ModuleRevisionId[] compileDependencies = { ModuleRevisionId.newInstance("aopalliance", "aopalliance", "1.0"), ModuleRevisionId.newInstance("com.googlecode.concurrentlinkedhashmap", "concurrentlinkedhashmap-lru", "1.2_jdk5"), diff --git a/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageBinding.java b/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageBinding.java index 1dd639e37ab..e9a400727f6 100644 --- a/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageBinding.java +++ b/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageBinding.java @@ -151,7 +151,7 @@ private void internalSetVariable(Binding bindingToUse, String name, Object value if (!GroovyPage.isReservedName(name)) { if (bindingToUse == null) { bindingToUse = findBindingForVariable(name); - if (bindingToUse == null || (bindingToUse instanceof GroovyPageBinding && ((GroovyPageBinding)bindingToUse).isRoot())) { + if (bindingToUse == null || (bindingToUse instanceof GroovyPageBinding && ((GroovyPageBinding)bindingToUse).shouldUseChildBinding(this))) { bindingToUse = this; } } @@ -172,6 +172,15 @@ private void internalSetVariable(Binding bindingToUse, String name, Object value } } + private boolean shouldUseChildBinding(GroovyPageBinding childBinding) { + return isRoot() || hasSameOwnerClass(childBinding); + } + + private boolean hasSameOwnerClass(GroovyPageBinding otherBinding) { + // owner class can be same in recursive rendering; in that case, the child binding should be used for setting variable values + return (getOwner() != null && otherBinding.getOwner() != null && getOwner().getClass()==otherBinding.getOwner().getClass()); + } + public String getPluginContextPath() { return (String)getVariable(GroovyPage.PLUGIN_CONTEXT_PATH); } diff --git a/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageWritable.java b/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageWritable.java index 626077b0c02..8ff3189a9e8 100644 --- a/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageWritable.java +++ b/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageWritable.java @@ -135,10 +135,7 @@ public Writer writeTo(Writer out) throws IOException { boolean newParentCreated = false; if (hasRequest) { - boolean isIncludeRequest = WebUtils.isIncludeRequest(request); - if(!isIncludeRequest) { - parentBinding = (GroovyPageBinding) request.getAttribute(GrailsApplicationAttributes.PAGE_SCOPE); - } + parentBinding = (GroovyPageBinding) request.getAttribute(GrailsApplicationAttributes.PAGE_SCOPE); if (parentBinding == null) { if (webRequest != null) { parentBinding = new GroovyPageBinding(new GroovyPageRequestBinding(webRequest)); diff --git a/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/util/WebUtils.java b/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/util/WebUtils.java index 5551b2eaced..21e3216d990 100644 --- a/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/util/WebUtils.java +++ b/grails-web/src/main/groovy/org/codehaus/groovy/grails/web/util/WebUtils.java @@ -49,6 +49,7 @@ import org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap; import org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest; import org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException; +import org.codehaus.groovy.grails.web.sitemesh.GrailsLayoutDecoratorMapper; import org.springframework.context.ApplicationContext; import org.springframework.util.Assert; import org.springframework.web.context.WebApplicationContext; @@ -335,8 +336,19 @@ public static IncludedContent includeForUrlMappingInfo(HttpServletRequest reques ModelAndView currentMv = null; Binding currentPageBinding = null; Map currentParams = null; + Object currentLayoutAttribute = null; + Object currentRenderingView = null; if (webRequest != null) { currentPageBinding = (Binding) webRequest.getAttribute(GrailsApplicationAttributes.PAGE_SCOPE, 0); + webRequest.removeAttribute(GrailsApplicationAttributes.PAGE_SCOPE, 0); + currentLayoutAttribute = webRequest.getAttribute(GrailsLayoutDecoratorMapper.LAYOUT_ATTRIBUTE, 0); + if(currentLayoutAttribute != null) { + webRequest.removeAttribute(GrailsLayoutDecoratorMapper.LAYOUT_ATTRIBUTE, 0); + } + currentRenderingView = webRequest.getAttribute(GrailsLayoutDecoratorMapper.RENDERING_VIEW, 0); + if(currentRenderingView != null) { + webRequest.removeAttribute(GrailsLayoutDecoratorMapper.RENDERING_VIEW, 0); + } currentController = webRequest.getControllerName(); currentAction = webRequest.getActionName(); currentId = webRequest.getId(); @@ -356,6 +368,12 @@ public static IncludedContent includeForUrlMappingInfo(HttpServletRequest reques finally { if (webRequest!=null) { webRequest.setAttribute(GrailsApplicationAttributes.PAGE_SCOPE,currentPageBinding, 0); + if(currentLayoutAttribute != null) { + webRequest.setAttribute(GrailsLayoutDecoratorMapper.LAYOUT_ATTRIBUTE, currentLayoutAttribute, 0); + } + if(currentRenderingView != null) { + webRequest.setAttribute(GrailsLayoutDecoratorMapper.RENDERING_VIEW, currentRenderingView, 0); + } webRequest.getParameterMap().clear(); webRequest.getParameterMap().putAll(currentParams); webRequest.setId(currentId);