org.codehaus.groovy.grails.web.pages.discovery
Class GrailsConventionGroovyPageLocator

java.lang.Object
  extended by org.codehaus.groovy.grails.web.pages.discovery.DefaultGroovyPageLocator
      extended by org.codehaus.groovy.grails.web.pages.discovery.GrailsConventionGroovyPageLocator
All Implemented Interfaces:
org.codehaus.groovy.grails.plugins.PluginManagerAware, GroovyPageLocator, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.web.context.ServletContextAware
Direct Known Subclasses:
CachingGrailsConventionGroovyPageLocator

public class GrailsConventionGroovyPageLocator
extends DefaultGroovyPageLocator

Extended GroovyPageLocator that deals with the details of Grails' conventions for controllers names, view names and template names

Since:
2.0

Nested Class Summary
 
Nested classes/interfaces inherited from class org.codehaus.groovy.grails.web.pages.discovery.DefaultGroovyPageLocator
DefaultGroovyPageLocator.PluginViewPathInfo
 
Field Summary
 
Fields inherited from class org.codehaus.groovy.grails.web.pages.discovery.DefaultGroovyPageLocator
pluginManager, reloadEnabled, resourceLoaders, warDeployed
 
Constructor Summary
GrailsConventionGroovyPageLocator()
           
 
Method Summary
 GroovyPageScriptSource findTemplate(java.lang.Object controller, java.lang.String templateName)
          Finds a template for the given controller name and template name
 GroovyPageScriptSource findTemplate(java.lang.String templateName)
          Finds a template for the given given template name, looking up the controller from the request as necessary
 GroovyPageScriptSource findTemplate(java.lang.String controllerName, java.lang.String templateName)
          Finds a template for the given controller name and template name
 GroovyPageScriptSource findTemplateByPath(java.lang.String uri)
          Find a template for a path.
 GroovyPageScriptSource findTemplateInBinding(java.lang.String templateName, GroovyPageBinding binding)
          Finds a template for the given given template name, looking up the controller from the request as necessary
 GroovyPageScriptSource findTemplateInBinding(java.lang.String pluginName, java.lang.String templateName, GroovyPageBinding binding)
          Finds a template for the given given template name, looking up the controller from the request as necessary
 GroovyPageScriptSource findView(java.lang.Object controller, java.lang.String viewName)
          Finds a view for the given controller and view name.
 GroovyPageScriptSource findView(java.lang.String viewName)
          Finds a view for the given given view name, looking up the controller from the request as necessary
 GroovyPageScriptSource findView(java.lang.String controllerName, java.lang.String viewName)
          Finds a view for the given controller name and view name.
 GroovyPageScriptSource findViewByPath(java.lang.String uri)
          Find a view for a path.
protected  java.lang.String getNameForController(java.lang.Object controller)
           
static java.lang.String resolveViewFormat(java.lang.String viewName)
           
 
Methods inherited from class org.codehaus.groovy.grails.web.pages.discovery.DefaultGroovyPageLocator
addResourceLoader, createGroovyPageCompiledScriptSource, findBinaryScriptSource, findPage, findPageInBinding, findPageInBinding, findReloadablePage, findResource, findResource, findResourceInPlugins, findResourceScriptPathForSearchPaths, findResourceScriptSource, findResourceScriptSourceInPlugins, getPluginViewPathInfo, isReloadEnabled, removePrecompiledPage, removePrefix, removeViewLocationPrefixes, resolveContextPath, resolvePluginViewPath, resolveSearchPaths, resolveViewInBinaryPlugin, setApplicationContext, setPluginManager, setPrecompiledGspMap, setReloadEnabled, setResourceLoader, setServletContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GrailsConventionGroovyPageLocator

public GrailsConventionGroovyPageLocator()
Method Detail

findViewByPath

public GroovyPageScriptSource findViewByPath(java.lang.String uri)
Find a view for a path. For example /foo/bar will search for /WEB-INF/grails-app/views/foo/bar.gsp in production and grails-app/views/foo/bar.gsp at development time

Parameters:
uri - The uri to search
Returns:
The script source

findView

public GroovyPageScriptSource findView(java.lang.String controllerName,
                                       java.lang.String viewName)

Finds a view for the given controller name and view name. For example specifying a controller name of "home" and a view name of "index" will search for /WEB-INF/grails-app/views/home/index.gsp in production and grails-app/views/home/index.gsp in development

This method will also detect the presence of the requested response format and try to resolve a more appropriate view. For example in the response format is 'xml' then /WEB-INF/grails-app/views/home/index.xml.gsp will be tried first

If the view is not found in the application then a scan is executed that searches through binary and source plugins looking for the first matching view name

Parameters:
controllerName - The controller name
viewName - The view name
Returns:
The GroovyPageScriptSource

resolveViewFormat

public static java.lang.String resolveViewFormat(java.lang.String viewName)

findView

public GroovyPageScriptSource findView(java.lang.Object controller,
                                       java.lang.String viewName)

Finds a view for the given controller and view name. For example specifying a controller with a class name of HomeController and a view name of "index" will search for /WEB-INF/grails-app/views/home/index.gsp in production and grails-app/views/home/index.gsp in development

If the view is not found in the application then a scan is executed that searches through binary and source plugins looking for the first matching view name

Parameters:
controller - The controller
viewName - The view name
Returns:
The GroovyPageScriptSource

findTemplate

public GroovyPageScriptSource findTemplate(java.lang.String controllerName,
                                           java.lang.String templateName)
Finds a template for the given controller name and template name

Parameters:
controllerName - The controller name
templateName - The view name
Returns:
The GroovyPageScriptSource

findTemplate

public GroovyPageScriptSource findTemplate(java.lang.Object controller,
                                           java.lang.String templateName)
Finds a template for the given controller name and template name

Parameters:
controller - The controller n
templateName - The view name
Returns:
The GroovyPageScriptSource

findView

public GroovyPageScriptSource findView(java.lang.String viewName)
Finds a view for the given given view name, looking up the controller from the request as necessary

Parameters:
viewName - The view name
Returns:
The GroovyPageScriptSource

findTemplate

public GroovyPageScriptSource findTemplate(java.lang.String templateName)
Finds a template for the given given template name, looking up the controller from the request as necessary

Parameters:
templateName - The template name
Returns:
The GroovyPageScriptSource

findTemplateInBinding

public GroovyPageScriptSource findTemplateInBinding(java.lang.String templateName,
                                                    GroovyPageBinding binding)
Finds a template for the given given template name, looking up the controller from the request as necessary

Parameters:
templateName - The template name
Returns:
The GroovyPageScriptSource

findTemplateInBinding

public GroovyPageScriptSource findTemplateInBinding(java.lang.String pluginName,
                                                    java.lang.String templateName,
                                                    GroovyPageBinding binding)
Finds a template for the given given template name, looking up the controller from the request as necessary

Parameters:
pluginName - The plugin
templateName - The template name
binding - The binding
Returns:
The GroovyPageScriptSource

findTemplateByPath

public GroovyPageScriptSource findTemplateByPath(java.lang.String uri)
Find a template for a path. For example /foo/bar will search for /WEB-INF/grails-app/views/foo/_bar.gsp in production and grails-app/views/foo/_bar.gsp at development time

Parameters:
uri - The uri to search
Returns:
The script source

getNameForController

protected java.lang.String getNameForController(java.lang.Object controller)