Skip to content

Commit

Permalink
Merge branch '2.0.x' of github.com:grails/grails-core into 2.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Brown committed May 22, 2012
2 parents 7aa5ab2 + ee7eb82 commit f92bc35
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit f92bc35

Please sign in to comment.