Search in sources :

Example 6 with GroovyPageScriptSource

use of org.grails.gsp.io.GroovyPageScriptSource in project grails-core by grails.

the class GroovyPageViewResolver method createGrailsView.

protected View createGrailsView(String viewName) throws Exception {
    // try GSP if res is null
    GroovyObject controller = null;
    GrailsWebRequest webRequest = GrailsWebRequest.lookup();
    if (webRequest != null) {
        HttpServletRequest request = webRequest.getCurrentRequest();
        controller = webRequest.getAttributes().getController(request);
    }
    GroovyPageScriptSource scriptSource;
    if (controller == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Locating GSP view for path {}", viewName);
        }
        scriptSource = groovyPageLocator.findViewByPath(viewName);
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Locating GSP view for controller {} and path {}", controller, viewName);
        }
        scriptSource = groovyPageLocator.findView(controller, viewName);
    }
    if (scriptSource != null) {
        return createGroovyPageView(scriptSource.getURI(), scriptSource);
    }
    return createFallbackView(viewName);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) GroovyPageScriptSource(org.grails.gsp.io.GroovyPageScriptSource) GrailsWebRequest(org.grails.web.servlet.mvc.GrailsWebRequest) GroovyObject(groovy.lang.GroovyObject)

Aggregations

GroovyPageScriptSource (org.grails.gsp.io.GroovyPageScriptSource)6 GrailsControllerClass (grails.core.GrailsControllerClass)3 GroovyObject (groovy.lang.GroovyObject)2 GrailsWebRequest (org.grails.web.servlet.mvc.GrailsWebRequest)2 CacheEntry (grails.util.CacheEntry)1 Template (groovy.text.Template)1 IOException (java.io.IOException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 GrailsTagException (org.grails.taglib.GrailsTagException)1