Skip to content

Commit e199a74

Browse files
committed
Save & restore GrailsLayoutDecoratorMapper.LAYOUT_ATTRIBUTE & RENDERING_VIEW before/after include request.
Possibly related to GRAILS-9005 .
1 parent 9d2fabb commit e199a74

File tree

1 file changed

+17
-0
lines changed
  • grails-web/src/main/groovy/org/codehaus/groovy/grails/web/util

1 file changed

+17
-0
lines changed

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

Lines changed: 17 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,9 +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);
340343
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+
}
341352
currentController = webRequest.getControllerName();
342353
currentAction = webRequest.getActionName();
343354
currentId = webRequest.getId();
@@ -357,6 +368,12 @@ public static IncludedContent includeForUrlMappingInfo(HttpServletRequest reques
357368
finally {
358369
if (webRequest!=null) {
359370
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+
}
360377
webRequest.getParameterMap().clear();
361378
webRequest.getParameterMap().putAll(currentParams);
362379
webRequest.setId(currentId);

0 commit comments

Comments
 (0)