Package org.grails.web.servlet.mvc

Examples of org.grails.web.servlet.mvc.GrailsWebRequest$DefaultEncodingStateRegistryLookup


     * @return The Template for the currently executing request
     * @throws java.io.IOException    Thrown when an exception occurs Reading the Template
     * @throws ClassNotFoundException  Thrown when the class of the template was not found
     */
    public Template createTemplate() {
        GrailsWebRequest webRequest = getWebRequest();
        String uri = getCurrentRequestUri(webRequest.getCurrentRequest());
        return createTemplate(uri);
    }
View Full Code Here


     *
     * @param viewName The view name
     * @return The GroovyPageScriptSource
     */
    public GroovyPageScriptSource findView(String viewName) {
        GrailsWebRequest webRequest = GrailsWebRequest.lookup();
        if (webRequest == null) {
            return findViewByPath(viewName);
        }
        return findView(webRequest.getControllerName(), viewName);
    }
View Full Code Here

     *
     * @param templateName The template name
     * @return The GroovyPageScriptSource
     */
    public GroovyPageScriptSource findTemplate(String templateName) {
        GrailsWebRequest webRequest = GrailsWebRequest.lookup();
        if (webRequest == null) {
            return findTemplateByPath(templateName);
        }
        return findTemplate(webRequest.getControllerName(), templateName);
    }
View Full Code Here

     *
     * @param templateName The template name
     * @return The GroovyPageScriptSource
     */
    public GroovyPageScriptSource findTemplateInBinding(String templateName, TemplateVariableBinding binding) {
        GrailsWebRequest webRequest = GrailsWebRequest.lookup();
        if (webRequest == null) {
            return findPageInBinding(uriService.getAbsoluteTemplateURI(templateName), binding);
        }
        return findPageInBinding(uriService.getTemplateURI(webRequest.getControllerName(), templateName), binding);
    }
View Full Code Here

     * @param templateName The template name
     * @param binding The binding
     * @return The GroovyPageScriptSource
     */
    public GroovyPageScriptSource findTemplateInBinding(String pluginName, String templateName, TemplateVariableBinding binding) {
        GrailsWebRequest webRequest = GrailsWebRequest.lookup();
        if (webRequest == null) {
            return findPageInBinding(pluginName, uriService.getAbsoluteTemplateURI(templateName), binding);
        }
        return findPageInBinding(pluginName, uriService.getTemplateURI(webRequest.getControllerName(), templateName), binding);
    }
View Full Code Here

            if(mimeType != null) {
                return mimeType.getExtension();
            }
        }
        else {
            GrailsWebRequest webRequest  =
                GrailsWebRequest.lookup();
            if(webRequest != null) {

                HttpServletRequest request = webRequest.getCurrentRequest();
                Object format = request.getAttribute(GrailsApplicationAttributes.RESPONSE_FORMAT);
                return format == null ? null : format.toString();
            }
        }
        return null;
View Full Code Here

    /*
     * Test method for 'GrailsLayoutDecoratorMapper.getDecorator(HttpServletRequest, Page)'
     */
    public void testGetDecoratorHttpServletRequestPage() throws Exception {
        GrailsWebRequest webRequest = buildMockRequest(null);
        webRequest.setAttribute(GrailsLayoutDecoratorMapper.RENDERING_VIEW, Boolean.TRUE, RequestAttributes.SCOPE_REQUEST);
        MockApplicationContext appCtx = (MockApplicationContext)webRequest.getApplicationContext();
        appCtx.registerMockResource("/grails-app/views/layouts/test.gsp", "<html><body><g:layoutBody /></body></html>");

        MockHttpServletRequest request = (MockHttpServletRequest)webRequest.getCurrentRequest();
        request.setMethod("GET");
        request.setRequestURI("orders/list");
        ServletContext context = webRequest.getServletContext();
        GrailsLayoutDecoratorMapper m = new GrailsLayoutDecoratorMapper();
        Config c = new Config(new MockServletConfig(context));
        m.init(c, null, null);
        HTMLPageParser parser = new HTMLPageParser();
        String html = "<html><head><title>Test title</title><meta name=\"layout\" content=\"test\"></meta></head><body>here is the body</body></html>";
View Full Code Here

        assertEquals("/layouts/test.gsp", d.getPage());
        assertEquals("test", d.getName());
    }

    public void testDecoratedByApplicationConventionForViewsNotRenderedByAController() throws Exception {
        GrailsWebRequest webRequest = buildMockRequest(null);
        webRequest.setAttribute(GrailsLayoutDecoratorMapper.RENDERING_VIEW, Boolean.TRUE, RequestAttributes.SCOPE_REQUEST);
        MockApplicationContext appCtx = (MockApplicationContext)webRequest.getApplicationContext();
        appCtx.registerMockResource("/grails-app/views/layouts/application.gsp", "<html><body><h1>Default Layout</h1><g:layoutBody /></body></html>");

        MockHttpServletRequest request = (MockHttpServletRequest)webRequest.getCurrentRequest();
        request.setMethod("GET");
        request.setRequestURI("/");

        ServletContext context = webRequest.getServletContext();

        GrailsLayoutDecoratorMapper m = new GrailsLayoutDecoratorMapper();
        Config c = new Config(new MockServletConfig(context));
        m.init(c, null, null);
        HTMLPageParser parser = new HTMLPageParser();
View Full Code Here

        assertEquals("/layouts/application.gsp", d.getPage());
        assertEquals("application", d.getName());
    }

    public void testDecoratedByApplicationConvention() throws Exception {
        GrailsWebRequest webRequest = buildMockRequest(null);
        webRequest.setAttribute(GrailsLayoutDecoratorMapper.RENDERING_VIEW, Boolean.TRUE, RequestAttributes.SCOPE_REQUEST);
        MockApplicationContext appCtx = (MockApplicationContext)webRequest.getApplicationContext();
        appCtx.registerMockResource("/grails-app/views/layouts/application.gsp", "<html><body><h1>Default Layout</h1><g:layoutBody /></body></html>");

        MockHttpServletRequest request = (MockHttpServletRequest)webRequest.getCurrentRequest();
        request.setMethod("GET");
        request.setRequestURI("orders/list");
        ServletContext context = webRequest.getServletContext();
        GroovyClassLoader gcl = new GroovyClassLoader();

        // create mock controller
        GroovyObject controller = (GroovyObject)gcl.parseClass("class FooController {\n" +
                "def controllerName = 'foo'\n" +
View Full Code Here

    public void testOverridingDefaultTemplateViaConfig() throws Exception {
            ConfigObject config = new ConfigSlurper().parse("grails.sitemesh.default.layout='otherApplication'");
            MutablePropertySources propertySources = new MutablePropertySources();
            propertySources.addLast(new MapPropertySource("grails", config));

            GrailsWebRequest webRequest = buildMockRequest(new PropertySourcesConfig(propertySources));
            webRequest.setAttribute(GrailsLayoutDecoratorMapper.RENDERING_VIEW, Boolean.TRUE, RequestAttributes.SCOPE_REQUEST);
            MockApplicationContext appCtx = (MockApplicationContext)webRequest.getApplicationContext();
            appCtx.registerMockResource("/grails-app/views/layouts/application.gsp", "<html><body><h1>Default Layout</h1><g:layoutBody /></body></html>");
            appCtx.registerMockResource("/grails-app/views/layouts/otherApplication.gsp", "<html><body><h1>Other Default Layout</h1><g:layoutBody /></body></html>");

            MockHttpServletRequest request = (MockHttpServletRequest)webRequest.getCurrentRequest();
            request.setMethod("GET");
            request.setRequestURI("orders/list");
            ServletContext context = webRequest.getServletContext();
            GroovyClassLoader gcl = new GroovyClassLoader();

            // create mock controller
            GroovyObject controller = (GroovyObject)gcl.parseClass("class FooController {\n" +
                    "def controllerName = 'foo'\n" +
View Full Code Here

TOP

Related Classes of org.grails.web.servlet.mvc.GrailsWebRequest$DefaultEncodingStateRegistryLookup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.