Class VelocityViewTag
- java.lang.Object
-
- javax.servlet.jsp.tagext.TagSupport
-
- javax.servlet.jsp.tagext.BodyTagSupport
-
- org.apache.velocity.tools.view.jsp.VelocityViewTag
-
- All Implemented Interfaces:
java.io.Serializable,javax.servlet.jsp.tagext.BodyTag,javax.servlet.jsp.tagext.IterationTag,javax.servlet.jsp.tagext.JspTag,javax.servlet.jsp.tagext.Tag
public class VelocityViewTag extends javax.servlet.jsp.tagext.BodyTagSupportThis tag enables use of Velocity and VelocityTools within JSP files and tags. This makes it trivial to render embedded VTL (Velocity Template Language) or include a separate Velocity template within a JSP using the current page context. This also automatically provides the typical
VelocityViewtoolbox support, much like the VelocityViewServlet and VelocityLayoutServlets have. In fact, this will by default share theVelocityViewinstance used with those servlets. This allows for consistent configuration and shared resources (better performance).- Since:
- VelocityTools 2.0
- Version:
- $Id: VelocityViewTag.java,v 1.1 2001/08/14 00:07:39 geirm Exp $
- Author:
- Nathan Bubna
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringbodyContentKeyprotected org.apache.velocity.tools.view.ViewToolContextcontextstatic java.lang.StringDEFAULT_BODY_CONTENT_KEYprotected org.apache.velocity.runtime.resource.util.StringResourceRepositoryrepositoryprotected java.lang.Stringscopeprotected java.lang.Stringtemplateprotected java.lang.Stringvarprotected org.apache.velocity.tools.view.VelocityViewview
-
Constructor Summary
Constructors Constructor Description VelocityViewTag()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcache(java.lang.String name, java.lang.String template)intdoEndTag()intdoStartTag()protected voidevalBody(java.io.Writer out)java.lang.StringgetBodyContentKey()java.lang.StringgetCache()protected java.lang.StringgetLogId()protected java.lang.StringgetRenderedBody()org.apache.velocity.runtime.resource.util.StringResourceRepositorygetRepository()java.lang.StringgetScope()java.lang.StringgetTemplate()java.lang.StringgetVar()org.apache.velocity.tools.view.VelocityViewgetVelocityView()org.apache.velocity.tools.view.ViewToolContextgetViewToolContext()protected booleanhasContent()protected voidinitializeView()protected booleanisCached()voidrelease()Release any per-instance resources, releasing any resources or state before this tag instance is disposed.protected voidrenderBody(java.io.Writer out)protected voidrenderContent(java.io.Writer out)protected voidreset()Release any per-invocation resources, resetting any resources or state that should be cleared between successive invocations ofTag.doEndTag()andTag.doStartTag().voidsetBodyContentKey(java.lang.String key)voidsetCache(java.lang.String s)voidsetId(java.lang.String id)voidsetRepository(org.apache.velocity.runtime.resource.util.StringResourceRepository repo)voidsetScope(java.lang.String scope)voidsetTemplate(java.lang.String template)voidsetVar(java.lang.String var)voidsetVelocityView(org.apache.velocity.tools.view.VelocityView view)voidsetViewToolContext(org.apache.velocity.tools.view.ViewToolContext context)protected static inttoScopeInt(java.lang.String scope)-
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, getBodyContent, getPreviousOut, setBodyContent
-
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setPageContext, setParent, setValue
-
-
-
-
Field Detail
-
DEFAULT_BODY_CONTENT_KEY
public static final java.lang.String DEFAULT_BODY_CONTENT_KEY
- See Also:
- Constant Field Values
-
view
protected transient org.apache.velocity.tools.view.VelocityView view
-
context
protected transient org.apache.velocity.tools.view.ViewToolContext context
-
repository
protected transient org.apache.velocity.runtime.resource.util.StringResourceRepository repository
-
var
protected java.lang.String var
-
scope
protected java.lang.String scope
-
template
protected java.lang.String template
-
bodyContentKey
protected java.lang.String bodyContentKey
-
-
Method Detail
-
reset
protected void reset()
Release any per-invocation resources, resetting any resources or state that should be cleared between successive invocations ofTag.doEndTag()andTag.doStartTag().
-
setId
public void setId(java.lang.String id)
- Overrides:
setIdin classjavax.servlet.jsp.tagext.TagSupport
-
getLogId
protected java.lang.String getLogId()
-
setVar
public void setVar(java.lang.String var)
-
getVar
public java.lang.String getVar()
-
setScope
public void setScope(java.lang.String scope)
-
getScope
public java.lang.String getScope()
-
setTemplate
public void setTemplate(java.lang.String template)
-
getTemplate
public java.lang.String getTemplate()
-
setBodyContentKey
public void setBodyContentKey(java.lang.String key)
-
getBodyContentKey
public java.lang.String getBodyContentKey()
-
setCache
public void setCache(java.lang.String s)
-
getCache
public java.lang.String getCache()
-
getVelocityView
public org.apache.velocity.tools.view.VelocityView getVelocityView()
-
setVelocityView
public void setVelocityView(org.apache.velocity.tools.view.VelocityView view)
-
getViewToolContext
public org.apache.velocity.tools.view.ViewToolContext getViewToolContext()
-
setViewToolContext
public void setViewToolContext(org.apache.velocity.tools.view.ViewToolContext context)
-
getRepository
public org.apache.velocity.runtime.resource.util.StringResourceRepository getRepository()
-
setRepository
public void setRepository(org.apache.velocity.runtime.resource.util.StringResourceRepository repo)
-
doStartTag
public int doStartTag() throws javax.servlet.jsp.JspException- Specified by:
doStartTagin interfacejavax.servlet.jsp.tagext.Tag- Overrides:
doStartTagin classjavax.servlet.jsp.tagext.BodyTagSupport- Throws:
javax.servlet.jsp.JspException
-
doEndTag
public int doEndTag() throws javax.servlet.jsp.JspException- Specified by:
doEndTagin interfacejavax.servlet.jsp.tagext.Tag- Overrides:
doEndTagin classjavax.servlet.jsp.tagext.BodyTagSupport- Throws:
javax.servlet.jsp.JspException
-
initializeView
protected void initializeView()
-
hasContent
protected boolean hasContent()
-
renderContent
protected void renderContent(java.io.Writer out) throws java.lang.Exception- Throws:
java.lang.Exception
-
getRenderedBody
protected java.lang.String getRenderedBody() throws java.lang.Exception- Throws:
java.lang.Exception
-
isCached
protected boolean isCached()
-
renderBody
protected void renderBody(java.io.Writer out) throws java.lang.Exception- Throws:
java.lang.Exception
-
evalBody
protected void evalBody(java.io.Writer out) throws java.lang.Exception- Throws:
java.lang.Exception
-
toScopeInt
protected static int toScopeInt(java.lang.String scope)
-
cache
protected void cache(java.lang.String name, java.lang.String template)
-
release
public void release()
Release any per-instance resources, releasing any resources or state before this tag instance is disposed.- Specified by:
releasein interfacejavax.servlet.jsp.tagext.Tag- Overrides:
releasein classjavax.servlet.jsp.tagext.BodyTagSupport- See Also:
Tag.release()
-
-