4949import org .codehaus .groovy .grails .web .servlet .mvc .GrailsParameterMap ;
5050import org .codehaus .groovy .grails .web .servlet .mvc .GrailsWebRequest ;
5151import org .codehaus .groovy .grails .web .servlet .mvc .exceptions .ControllerExecutionException ;
52+ import org .codehaus .groovy .grails .web .sitemesh .GrailsLayoutDecoratorMapper ;
5253import org .springframework .context .ApplicationContext ;
5354import org .springframework .util .Assert ;
5455import 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