|
||||||||||
PREV CLASS NEXT CLASS | 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
A GroovyPagesTemplateEngine 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 String |
BEAN_ID
|
static String |
RESOURCE_LOADER_BEAN_ID
|
Constructor Summary | |
---|---|
GroovyPagesTemplateEngine()
|
|
GroovyPagesTemplateEngine(ServletContext servletContext)
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
protected GroovyPageMetaInfo |
buildPageMetaInfo(InputStream inputStream,
Resource res,
String pageName)
Constructs a GroovyPageMetaInfo instance which holds the script class, modified date and so on |
int[] |
calculateLineNumbersForPage(ServletContext context,
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()
Creates a Template for the currently executing Request |
groovy.text.Template |
createTemplate(File file)
Creates a Template for the given file |
groovy.text.Template |
createTemplate(InputStream inputStream)
Create a Template for the given InputStream |
protected groovy.text.Template |
createTemplate(InputStream inputStream,
Resource resource,
String pageName)
Constructs a Groovy Template from the given InputStream and Spring Resource object |
groovy.text.Template |
createTemplate(Resource resource)
Creates a Template for the given Spring Resource instance |
groovy.text.Template |
createTemplate(String uri)
Creates a Template using the given URI. |
groovy.text.Template |
createTemplate(String txt,
String pageName)
Creates a Template using the given text for the Template and the given name. |
groovy.text.Template |
createTemplate(URL url)
Creates a Template for the given URL |
groovy.text.Template |
createTemplateForUri(String uri)
|
groovy.text.Template |
createTemplateForUri(String[] uri)
|
protected String |
establishPageName(Resource res,
String pageName)
Establishes the name to use for the given resource |
protected String |
getCurrentRequestUri(HttpServletRequest request)
Return the page identifier. |
Map<String,String> |
getPrecompiledGspMap()
|
protected String |
getUriWithinGrailsViews(String relativeUri)
Returns the path to the view of the relative URI within the Grails views directory |
boolean |
isReloadEnabled()
Return whether reload is enabled for the GroovyPagesTemplateEngine |
void |
setApplicationContext(ApplicationContext applicationContext)
Sets the ResourceLoader from the ApplicationContext |
void |
setClassLoader(ClassLoader classLoader)
Sets the ClassLoader that the TemplateEngine should use to |
void |
setJspTagLibraryResolver(TagLibraryResolver jspTagLibraryResolver)
|
void |
setPrecompiledGspMap(Map<String,String> 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 org.codehaus.groovy.grails.support.ResourceAwareTemplateEngine |
---|
createTemplate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String BEAN_ID
public static final String RESOURCE_LOADER_BEAN_ID
Constructor Detail |
---|
public GroovyPagesTemplateEngine()
public GroovyPagesTemplateEngine(ServletContext servletContext)
Method Detail |
---|
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
public void setTagLibraryLookup(TagLibraryLookup tagLibraryLookup)
public void setJspTagLibraryResolver(TagLibraryResolver jspTagLibraryResolver)
public void setClassLoader(ClassLoader classLoader)
classLoader
- The ClassLoader to use when compilation of Groovy Pages occurspublic void setResourceLoader(ResourceLoader resourceLoader)
resourceLoader
- The ResourceLoader instancepublic int[] calculateLineNumbersForPage(ServletContext context, String url)
context
- The ServletContext instanceurl
- The URL of the page
public groovy.text.Template createTemplate(Resource resource)
createTemplate
in class ResourceAwareTemplateEngine
resource
- The Resource to create the Template for
public groovy.text.Template createTemplate(String uri)
createTemplate
in class groovy.text.TemplateEngine
uri
- The URI of the page to create the template for
org.codehaus.groovy.control.CompilationFailedException
public groovy.text.Template createTemplateForUri(String uri)
public groovy.text.Template createTemplateForUri(String[] uri)
public groovy.text.Template createTemplate(String txt, String pageName) throws IOException
txt
- The URI of the page to create the template forpageName
- The name of the page being parsed
org.codehaus.groovy.control.CompilationFailedException
IOException
- Thrown if an IO exception occurs creating the Templatepublic groovy.text.Template createTemplate() throws IOException, ClassNotFoundException
IOException
- Thrown when an exception occurs Reading the Template
ClassNotFoundException
- Thrown when the class of the template was not foundpublic groovy.text.Template createTemplate(File file) throws org.codehaus.groovy.control.CompilationFailedException, ClassNotFoundException, IOException
createTemplate
in class groovy.text.TemplateEngine
file
- The File to use to construct the template with
org.codehaus.groovy.control.CompilationFailedException
- When an error occured compiling the Template
ClassNotFoundException
- When a Class cannot be found within the given Template
IOException
- When a I/O Exception occurs reading the Templatepublic groovy.text.Template createTemplate(URL url) throws org.codehaus.groovy.control.CompilationFailedException, ClassNotFoundException, IOException
createTemplate
in class groovy.text.TemplateEngine
url
- The URL to use to construct the template with
org.codehaus.groovy.control.CompilationFailedException
- When an error occured compiling the Template
ClassNotFoundException
- When a Class cannot be found within the given Template
IOException
- When a I/O Exception occurs reading the Templatepublic groovy.text.Template createTemplate(InputStream inputStream)
createTemplate
in class ResourceAwareTemplateEngine
inputStream
- The InputStream to create the Template for
protected groovy.text.Template createTemplate(InputStream inputStream, Resource resource, String pageName)
inputStream
- The InputStream to useresource
- The Resource to usepageName
- The name of the page
public boolean isReloadEnabled()
public void setReloadEnabled(boolean b)
b
- True if it is enabledprotected GroovyPageMetaInfo buildPageMetaInfo(InputStream inputStream, Resource res, 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)
protected String establishPageName(Resource res, 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
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext
in interface ApplicationContextAware
applicationContext
- The ApplicationContext
BeansException
- Thrown when an error occurs with the ApplicationContextprotected String getCurrentRequestUri(HttpServletRequest request)
request
- The HttpServletRequest instance
protected String getUriWithinGrailsViews(String relativeUri)
relativeUri
- The relative URI
public void setServletContext(ServletContext servletContext)
setServletContext
in interface ServletContextAware
public void clearPageCache()
public Map<String,String> getPrecompiledGspMap()
public void setPrecompiledGspMap(Map<String,String> precompiledGspMap)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |