org.apache.velocity.tools.view.jsp
Class VelocityViewTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by org.apache.velocity.tools.view.jsp.VelocityViewTag
All Implemented Interfaces:
Serializable, BodyTag, IterationTag, JspTag, Tag

public class VelocityViewTag
extends BodyTagSupport

This 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 VelocityView toolbox support, much like the VelocityViewServlet and VelocityLayoutServlets have. In fact, this will by default share the VelocityView instance 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
protected  String bodyContentKey
           
protected  ViewToolContext context
           
static String DEFAULT_BODY_CONTENT_KEY
           
protected  org.apache.velocity.runtime.resource.util.StringResourceRepository repository
           
protected  String scope
           
protected  String template
           
protected  String var
           
protected  VelocityView view
           
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
VelocityViewTag()
           
 
Method Summary
protected  void cache(String name, String template)
           
 int doEndTag()
           
 int doStartTag()
           
protected  void evalBody(Writer out)
           
 String getBodyContentKey()
           
 String getCache()
           
protected  String getLogId()
           
protected  String getRenderedBody()
           
 org.apache.velocity.runtime.resource.util.StringResourceRepository getRepository()
           
 String getScope()
           
 String getTemplate()
           
 String getVar()
           
 VelocityView getVelocityView()
           
 ViewToolContext getViewToolContext()
           
protected  boolean hasContent()
           
protected  void initializeView()
           
protected  boolean isCached()
           
 void release()
          Release any per-instance resources, releasing any resources or state before this tag instance is disposed.
protected  void renderBody(Writer out)
           
protected  void renderContent(Writer out)
           
protected  void reset()
          Release any per-invocation resources, resetting any resources or state that should be cleared between successive invocations of Tag.doEndTag() and Tag.doStartTag().
 void setBodyContentKey(String key)
           
 void setCache(String s)
           
 void setId(String id)
           
 void setRepository(org.apache.velocity.runtime.resource.util.StringResourceRepository repo)
           
 void setScope(String scope)
           
 void setTemplate(String template)
           
 void setVar(String var)
           
 void setVelocityView(VelocityView view)
           
 void setViewToolContext(ViewToolContext context)
           
protected static int toScopeInt(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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
 

Field Detail

DEFAULT_BODY_CONTENT_KEY

public static final String DEFAULT_BODY_CONTENT_KEY
See Also:
Constant Field Values

view

protected transient VelocityView view

context

protected transient ViewToolContext context

repository

protected transient org.apache.velocity.runtime.resource.util.StringResourceRepository repository

var

protected String var

scope

protected String scope

template

protected String template

bodyContentKey

protected String bodyContentKey
Constructor Detail

VelocityViewTag

public VelocityViewTag()
Method Detail

reset

protected void reset()
Release any per-invocation resources, resetting any resources or state that should be cleared between successive invocations of Tag.doEndTag() and Tag.doStartTag().


setId

public void setId(String id)
Overrides:
setId in class TagSupport

getLogId

protected String getLogId()

setVar

public void setVar(String var)

getVar

public String getVar()

setScope

public void setScope(String scope)

getScope

public String getScope()

setTemplate

public void setTemplate(String template)

getTemplate

public String getTemplate()

setBodyContentKey

public void setBodyContentKey(String key)

getBodyContentKey

public String getBodyContentKey()

setCache

public void setCache(String s)

getCache

public String getCache()

getVelocityView

public VelocityView getVelocityView()

setVelocityView

public void setVelocityView(VelocityView view)

getViewToolContext

public ViewToolContext getViewToolContext()

setViewToolContext

public void setViewToolContext(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 JspException
Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class BodyTagSupport
Throws:
JspException

doEndTag

public int doEndTag()
             throws JspException
Specified by:
doEndTag in interface Tag
Overrides:
doEndTag in class BodyTagSupport
Throws:
JspException

initializeView

protected void initializeView()

hasContent

protected boolean hasContent()

renderContent

protected void renderContent(Writer out)
                      throws Exception
Throws:
Exception

getRenderedBody

protected String getRenderedBody()
                          throws Exception
Throws:
Exception

isCached

protected boolean isCached()

renderBody

protected void renderBody(Writer out)
                   throws Exception
Throws:
Exception

evalBody

protected void evalBody(Writer out)
                 throws Exception
Throws:
Exception

toScopeInt

protected static int toScopeInt(String scope)

cache

protected void cache(String name,
                     String template)

release

public void release()
Release any per-instance resources, releasing any resources or state before this tag instance is disposed.

Specified by:
release in interface Tag
Overrides:
release in class BodyTagSupport
See Also:
Tag.release()


Copyright © 2002-2011 The Apache Software Foundation. All Rights Reserved.