|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovy.text.TemplateEngine org.codehaus.groovy.grails.support.ResourceAwareTemplateEngine org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine
public class GroovyPagesTemplateEngine extends ResourceAwareTemplateEngine
Based on (but not extending) the existing TemplateEngine implementations
within Groovy. It allows GSP pages to be re-used in different context using code like the below:
Template t = new GroovyPagesTemplateEngine()
.createTemplate(context,request,response);
t.make()
.writeTo(out);
Field Summary | |
---|---|
static java.lang.String |
BEAN_ID
|
static java.lang.String |
CONFIG_PROPERTY_DISABLE_CACHING_RESOURCES
|
static java.lang.String |
CONFIG_PROPERTY_GSP_ENABLE_RELOAD
|
static java.lang.String |
RESOURCE_LOADER_BEAN_ID
|
Constructor Summary | |
GroovyPagesTemplateEngine()
|
|
GroovyPagesTemplateEngine(ServletContext servletContext)
|
Method Summary | |
---|---|
void
|
afterPropertiesSet()
|
protected GroovyPageMetaInfo
|
buildPageMetaInfo(java.io.InputStream inputStream, Resource res, java.lang.String pageName)
Constructs a GroovyPageMetaInfo instance which holds the script class, modified date and so on |
int[]
|
calculateLineNumbersForPage(ServletContext context, java.lang.String url)
Retrieves a line number matrix for the specified page that can be used to retrieve the actual line number within the GSP page if the line number within the compiled GSP is known |
void
|
clearPageCache()
Clears the page cache. |
groovy.text.Template
|
createTemplate(Resource resource)
Creates a Template for the given Spring Resource instance |
groovy.text.Template
|
createTemplate(Resource resource, boolean cacheable)
Creates a Template for the given Spring Resource instance |
groovy.text.Template
|
createTemplate(java.lang.String uri)
Creates a Template using the given URI. |
groovy.text.Template
|
createTemplate(java.lang.String txt, java.lang.String pageName)
Creates a Template using the given text for the Template and the given name. |
groovy.text.Template
|
createTemplate()
Creates a Template for the currently executing Request |
groovy.text.Template
|
createTemplate(java.io.File file)
Creates a Template for the given file |
groovy.text.Template
|
createTemplate(java.net.URL url)
Creates a Template for the given URL |
groovy.text.Template
|
createTemplate(java.io.InputStream inputStream)
Create a Template for the given InputStream |
protected groovy.text.Template
|
createTemplate(java.io.InputStream inputStream, Resource resource, java.lang.String pageName)
Constructs a Groovy Template from the given InputStream and Spring Resource object |
groovy.text.Template
|
createTemplateForUri(java.lang.String uri)
|
groovy.text.Template
|
createTemplateForUri(String[] uri)
|
protected java.lang.String
|
establishPageName(Resource res, java.lang.String pageName)
Establishes the name to use for the given resource |
protected java.lang.String
|
getCurrentRequestUri(HttpServletRequest request)
Return the page identifier. |
java.util.Map
|
getPrecompiledGspMap()
|
protected java.lang.String
|
getUriWithinGrailsViews(java.lang.String relativeUri)
Returns the path to the view of the relative URI within the Grails views directory |
boolean
|
isCacheResources()
|
boolean
|
isReloadEnabled()
Return whether reload is enabled for the GroovyPagesTemplateEngine |
void
|
setApplicationContext(ApplicationContext applicationContext)
Sets the ResourceLoader from the ApplicationContext |
void
|
setCacheResources(boolean cacheResources)
|
void
|
setClassLoader(java.lang.ClassLoader classLoader)
Sets the ClassLoader that the TemplateEngine should use to |
void
|
setJspTagLibraryResolver(TagLibraryResolver jspTagLibraryResolver)
|
void
|
setPrecompiledGspMap(java.util.Map precompiledGspMap)
|
void
|
setReloadEnabled(boolean b)
Sets whether reloading is enabled |
void
|
setResourceLoader(ResourceLoader resourceLoader)
Sets a custom ResourceLoader that will be used to load GSPs for URIs |
void
|
setServletContext(ServletContext servletContext)
|
void
|
setTagLibraryLookup(TagLibraryLookup tagLibraryLookup)
|
Methods inherited from class ResourceAwareTemplateEngine | |
---|---|
createTemplate, createTemplate, createTemplate, createTemplate, createTemplate, createTemplate, createTemplate |
Methods inherited from class groovy.text.TemplateEngine | |
---|---|
groovy.text.TemplateEngine#createTemplate(java.io.Reader), groovy.text.TemplateEngine#createTemplate(java.lang.String), groovy.text.TemplateEngine#createTemplate(java.io.File), groovy.text.TemplateEngine#createTemplate(java.net.URL), groovy.text.TemplateEngine#wait(), groovy.text.TemplateEngine#wait(long), groovy.text.TemplateEngine#wait(long, int), groovy.text.TemplateEngine#equals(java.lang.Object), groovy.text.TemplateEngine#toString(), groovy.text.TemplateEngine#hashCode(), groovy.text.TemplateEngine#getClass(), groovy.text.TemplateEngine#notify(), groovy.text.TemplateEngine#notifyAll() |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
public static final java.lang.String BEAN_ID
public static final java.lang.String CONFIG_PROPERTY_DISABLE_CACHING_RESOURCES
public static final java.lang.String CONFIG_PROPERTY_GSP_ENABLE_RELOAD
public static final java.lang.String RESOURCE_LOADER_BEAN_ID
Constructor Detail |
---|
public GroovyPagesTemplateEngine()
public GroovyPagesTemplateEngine(ServletContext servletContext)
Method Detail |
---|
public void afterPropertiesSet()
protected GroovyPageMetaInfo buildPageMetaInfo(java.io.InputStream inputStream, Resource res, java.lang.String pageName)
inputStream
- The InputStream to construct the GroovyPageMetaInfo instance fromres
- The Spring Resource to construct the MetaInfo frompageName
- The name of the page (can be null, in which case method responsible for calculating appropriate alternative)
public int[] calculateLineNumbersForPage(@SuppressWarnings("unused") ServletContext context, java.lang.String url)
context
- The ServletContext instanceurl
- The URL of the page
public void clearPageCache()
@Override public groovy.text.Template createTemplate(Resource resource)
resource
- The Resource to create the Template for
@Override public groovy.text.Template createTemplate(Resource resource, boolean cacheable)
resource
- The Resource to create the Template forcacheable
- The resource can be cached or not
@Override public groovy.text.Template createTemplate(java.lang.String uri)
uri
- The URI of the page to create the template for
public groovy.text.Template createTemplate(java.lang.String txt, java.lang.String pageName)
txt
- The URI of the page to create the template forpageName
- The name of the page being parsed
public groovy.text.Template createTemplate()
@Override public groovy.text.Template createTemplate(java.io.File file)
file
- The File to use to construct the template with
@Override public groovy.text.Template createTemplate(java.net.URL url)
url
- The URL to use to construct the template with
@Override public groovy.text.Template createTemplate(java.io.InputStream inputStream)
inputStream
- The InputStream to create the Template for
protected groovy.text.Template createTemplate(java.io.InputStream inputStream, Resource resource, java.lang.String pageName)
inputStream
- The InputStream to useresource
- The Resource to usepageName
- The name of the page
public groovy.text.Template createTemplateForUri(java.lang.String uri)
public groovy.text.Template createTemplateForUri(String[] uri)
protected java.lang.String establishPageName(Resource res, java.lang.String pageName)
res
- The Resource to calculate the name forpageName
- The name of the page, can be null, in which case method responsible for calculation
protected java.lang.String getCurrentRequestUri(HttpServletRequest request)
request
- The HttpServletRequest instance
public java.util.Map getPrecompiledGspMap()
protected java.lang.String getUriWithinGrailsViews(java.lang.String relativeUri)
relativeUri
- The relative URI
public boolean isCacheResources()
public boolean isReloadEnabled()
public void setApplicationContext(ApplicationContext applicationContext)
applicationContext
- The ApplicationContext
public void setCacheResources(boolean cacheResources)
public void setClassLoader(java.lang.ClassLoader classLoader)
classLoader
- The ClassLoader to use when compilation of Groovy Pages occurs
public void setJspTagLibraryResolver(TagLibraryResolver jspTagLibraryResolver)
public void setPrecompiledGspMap(java.util.Map precompiledGspMap)
public void setReloadEnabled(boolean b)
b
- True if it is enabled
public void setResourceLoader(ResourceLoader resourceLoader)
resourceLoader
- The ResourceLoader instance
public void setServletContext(ServletContext servletContext)
public void setTagLibraryLookup(TagLibraryLookup tagLibraryLookup)
Groovy Documentation