diff --git a/grails-plugin-controllers/src/main/groovy/grails/artefact/controller/support/ResponseRenderer.groovy b/grails-plugin-controllers/src/main/groovy/grails/artefact/controller/support/ResponseRenderer.groovy index 9c30cb18b8..9b13926d0f 100644 --- a/grails-plugin-controllers/src/main/groovy/grails/artefact/controller/support/ResponseRenderer.groovy +++ b/grails-plugin-controllers/src/main/groovy/grails/artefact/controller/support/ResponseRenderer.groovy @@ -37,8 +37,8 @@ import org.grails.web.servlet.mvc.GrailsWebRequest import org.grails.web.servlet.mvc.exceptions.ControllerExecutionException import org.grails.web.servlet.view.CompositeViewResolver import org.grails.web.servlet.view.GroovyPageView -import org.grails.plugins.web.controllers.ControllersGrailsPlugin import org.grails.web.util.GrailsApplicationAttributes +import org.grails.web.util.WebUtils import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Qualifier import org.springframework.http.HttpStatus @@ -296,7 +296,7 @@ trait ResponseRenderer extends WebAttributes { } - boolean renderWithLayout = (explicitSiteMeshLayout || webRequest.getCurrentRequest().getAttribute(ControllersGrailsPlugin.LAYOUT_ATTRIBUTE)) + boolean renderWithLayout = (explicitSiteMeshLayout || webRequest.getCurrentRequest().getAttribute(WebUtils.LAYOUT_ATTRIBUTE)) // if automatic decoration occurred unwrap, since this is a partial if (renderWithLayout) { @@ -533,13 +533,13 @@ trait ResponseRenderer extends WebAttributes { } private void applySiteMeshLayout(HttpServletRequest request, boolean renderView, String explicitSiteMeshLayout) { - if(explicitSiteMeshLayout == null && request.getAttribute(ControllersGrailsPlugin.LAYOUT_ATTRIBUTE) != null) { + if(explicitSiteMeshLayout == null && request.getAttribute(WebUtils.LAYOUT_ATTRIBUTE) != null) { // layout has been set already return } - String siteMeshLayout = explicitSiteMeshLayout != null ? explicitSiteMeshLayout : (renderView ? null : ControllersGrailsPlugin.NONE_LAYOUT) + String siteMeshLayout = explicitSiteMeshLayout != null ? explicitSiteMeshLayout : (renderView ? null : WebUtils.NONE_LAYOUT) if(siteMeshLayout != null) { - request.setAttribute ControllersGrailsPlugin.LAYOUT_ATTRIBUTE, siteMeshLayout + request.setAttribute WebUtils.LAYOUT_ATTRIBUTE, siteMeshLayout } } diff --git a/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersGrailsPlugin.groovy b/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersGrailsPlugin.groovy index 5bd61c27a9..40c851156d 100644 --- a/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersGrailsPlugin.groovy +++ b/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersGrailsPlugin.groovy @@ -41,8 +41,6 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry import org.springframework.web.servlet.config.annotation.WebMvcConfigurer import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping -import org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator - import jakarta.servlet.DispatcherType import jakarta.servlet.MultipartConfigElement @@ -63,11 +61,6 @@ class ControllersGrailsPlugin extends Plugin { def observe = ['domainClass'] def dependsOn = [core: version, i18n: version, urlMappings: version] - // Although they are specific to Sitemesh, these properties need - // a new home that is not coupled to any sitemesh dependency - static final String LAYOUT_ATTRIBUTE = "org.grails.layout.name"; - static final String NONE_LAYOUT = "_none_"; - @Override Closure doWithSpring(){ { -> def application = grailsApplication diff --git a/grails-test-suite-uber/src/test/groovy/org/grails/web/servlet/mvc/RenderDynamicMethodTests.groovy b/grails-test-suite-uber/src/test/groovy/org/grails/web/servlet/mvc/RenderDynamicMethodTests.groovy index f3c8216ae3..2073d495c5 100644 --- a/grails-test-suite-uber/src/test/groovy/org/grails/web/servlet/mvc/RenderDynamicMethodTests.groovy +++ b/grails-test-suite-uber/src/test/groovy/org/grails/web/servlet/mvc/RenderDynamicMethodTests.groovy @@ -1,7 +1,7 @@ package org.grails.web.servlet.mvc -import org.grails.plugins.web.controllers.ControllersGrailsPlugin import grails.testing.web.controllers.ControllerUnitTest +import org.grails.web.util.WebUtils import spock.lang.Specification import grails.artefact.Artefact import org.grails.buffer.FastStringWriter @@ -15,7 +15,7 @@ class RenderDynamicMethodTests extends Specification implements ControllerUnitTe then: response.contentType == response.contentType response.contentAsString == response.contentAsString - request.getAttribute(ControllersGrailsPlugin.LAYOUT_ATTRIBUTE) == "bar" + request.getAttribute(WebUtils.LAYOUT_ATTRIBUTE) == "bar" } void testRenderView() { diff --git a/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java b/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java index 5fa4c81f8c..029a6e824e 100644 --- a/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java +++ b/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java @@ -60,6 +60,7 @@ public class WebUtils extends org.springframework.web.util.WebUtils { public static final String DISPATCH_ACTION_PARAMETER = "_action_"; public static final String SEND_ALLOW_HEADER_FOR_INVALID_HTTP_METHOD = "grails.http.invalid.method.allow.header"; public static final String LAYOUT_ATTRIBUTE = "org.grails.layout.name"; + public static final String NONE_LAYOUT = "_none_"; public static final String RENDERING_VIEW = "org.grails.rendering.view"; public static final String GRAILS_DISPATCH_EXTENSION = ".dispatch"; public static final String GRAILS_SERVLET_PATH = "/grails";