Skip to content

Commit f92bc35

Browse files
Merge branch '2.0.x' of github.com:grails/grails-core into 2.0.x
2 parents 7aa5ab2 + ee7eb82 commit f92bc35

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ext {
2424
commonsCollectionsVersion = "3.2.1"
2525
commonsIOVersion = "2.1"
2626
commonsLangVersion = "2.6"
27-
datastoreVersion = "1.0.7.RELEASE"
27+
datastoreVersion = "1.0.9.RELEASE"
2828
gantVersion = "1.9.6"
2929
gdocEngineVersion = "1.0.1"
3030
groovyVersion = "1.8.6"

grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/GrailsCoreDependencies.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public Object doCall() {
192192
};
193193
registerDependencies(dependencyManager, compileTimeDependenciesMethod, commonsExcludingLoggingAndXmlApis, "commons-logging", "xml-apis", "commons-digester");
194194

195-
String datastoreMappingVersion = "1.0.7.RELEASE";
195+
String datastoreMappingVersion = "1.0.9.RELEASE";
196196
ModuleRevisionId[] compileDependencies = {
197197
ModuleRevisionId.newInstance("aopalliance", "aopalliance", "1.0"),
198198
ModuleRevisionId.newInstance("com.googlecode.concurrentlinkedhashmap", "concurrentlinkedhashmap-lru", "1.2_jdk5"),

grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageBinding.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private void internalSetVariable(Binding bindingToUse, String name, Object value
151151
if (!GroovyPage.isReservedName(name)) {
152152
if (bindingToUse == null) {
153153
bindingToUse = findBindingForVariable(name);
154-
if (bindingToUse == null || (bindingToUse instanceof GroovyPageBinding && ((GroovyPageBinding)bindingToUse).isRoot())) {
154+
if (bindingToUse == null || (bindingToUse instanceof GroovyPageBinding && ((GroovyPageBinding)bindingToUse).shouldUseChildBinding(this))) {
155155
bindingToUse = this;
156156
}
157157
}
@@ -172,6 +172,15 @@ private void internalSetVariable(Binding bindingToUse, String name, Object value
172172
}
173173
}
174174

175+
private boolean shouldUseChildBinding(GroovyPageBinding childBinding) {
176+
return isRoot() || hasSameOwnerClass(childBinding);
177+
}
178+
179+
private boolean hasSameOwnerClass(GroovyPageBinding otherBinding) {
180+
// owner class can be same in recursive rendering; in that case, the child binding should be used for setting variable values
181+
return (getOwner() != null && otherBinding.getOwner() != null && getOwner().getClass()==otherBinding.getOwner().getClass());
182+
}
183+
175184
public String getPluginContextPath() {
176185
return (String)getVariable(GroovyPage.PLUGIN_CONTEXT_PATH);
177186
}

grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageWritable.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ public Writer writeTo(Writer out) throws IOException {
135135
boolean newParentCreated = false;
136136

137137
if (hasRequest) {
138-
boolean isIncludeRequest = WebUtils.isIncludeRequest(request);
139-
if(!isIncludeRequest) {
140-
parentBinding = (GroovyPageBinding) request.getAttribute(GrailsApplicationAttributes.PAGE_SCOPE);
141-
}
138+
parentBinding = (GroovyPageBinding) request.getAttribute(GrailsApplicationAttributes.PAGE_SCOPE);
142139
if (parentBinding == null) {
143140
if (webRequest != null) {
144141
parentBinding = new GroovyPageBinding(new GroovyPageRequestBinding(webRequest));

grails-web/src/main/groovy/org/codehaus/groovy/grails/web/util/WebUtils.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap;
5050
import org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest;
5151
import org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException;
52+
import org.codehaus.groovy.grails.web.sitemesh.GrailsLayoutDecoratorMapper;
5253
import org.springframework.context.ApplicationContext;
5354
import org.springframework.util.Assert;
5455
import org.springframework.web.context.WebApplicationContext;
@@ -335,8 +336,19 @@ public static IncludedContent includeForUrlMappingInfo(HttpServletRequest reques
335336
ModelAndView currentMv = null;
336337
Binding currentPageBinding = null;
337338
Map currentParams = null;
339+
Object currentLayoutAttribute = null;
340+
Object currentRenderingView = null;
338341
if (webRequest != null) {
339342
currentPageBinding = (Binding) webRequest.getAttribute(GrailsApplicationAttributes.PAGE_SCOPE, 0);
343+
webRequest.removeAttribute(GrailsApplicationAttributes.PAGE_SCOPE, 0);
344+
currentLayoutAttribute = webRequest.getAttribute(GrailsLayoutDecoratorMapper.LAYOUT_ATTRIBUTE, 0);
345+
if(currentLayoutAttribute != null) {
346+
webRequest.removeAttribute(GrailsLayoutDecoratorMapper.LAYOUT_ATTRIBUTE, 0);
347+
}
348+
currentRenderingView = webRequest.getAttribute(GrailsLayoutDecoratorMapper.RENDERING_VIEW, 0);
349+
if(currentRenderingView != null) {
350+
webRequest.removeAttribute(GrailsLayoutDecoratorMapper.RENDERING_VIEW, 0);
351+
}
340352
currentController = webRequest.getControllerName();
341353
currentAction = webRequest.getActionName();
342354
currentId = webRequest.getId();
@@ -356,6 +368,12 @@ public static IncludedContent includeForUrlMappingInfo(HttpServletRequest reques
356368
finally {
357369
if (webRequest!=null) {
358370
webRequest.setAttribute(GrailsApplicationAttributes.PAGE_SCOPE,currentPageBinding, 0);
371+
if(currentLayoutAttribute != null) {
372+
webRequest.setAttribute(GrailsLayoutDecoratorMapper.LAYOUT_ATTRIBUTE, currentLayoutAttribute, 0);
373+
}
374+
if(currentRenderingView != null) {
375+
webRequest.setAttribute(GrailsLayoutDecoratorMapper.RENDERING_VIEW, currentRenderingView, 0);
376+
}
359377
webRequest.getParameterMap().clear();
360378
webRequest.getParameterMap().putAll(currentParams);
361379
webRequest.setId(currentId);

0 commit comments

Comments
 (0)