freemarker.ext.jsp
Class FreeMarkerTag

java.lang.Object
  extended by freemarker.ext.jsp.FreeMarkerTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.Tag

public class FreeMarkerTag
extends java.lang.Object
implements javax.servlet.jsp.tagext.BodyTag

Simple implementation of JSP tag to allow use of FM-Classic templates in JSP. Inspired by similar class in Velocity template engine developed by Geir Magnusson Jr.

Version:
$Id: FreeMarkerTag.java 1123 2013-04-12 05:49:16Z run2000 $
Author:
Attila Szegedi, szegedia@freemail.hu

Field Summary
 
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
FreeMarkerTag()
           
 
Method Summary
 int doAfterBody()
          Process body (re)evaluation.
 int doEndTag()
          Process the end tag for this instance.
 void doInitBody()
          Prepare for evaluation of the body.
 int doStartTag()
          Process the start tag for this instance.
 boolean getCaching()
          Retrieve whether we're caching template content from the body, or whether we recompile the template each time.
 javax.servlet.jsp.tagext.Tag getParent()
          Get the parent (closest enclosing tag handler) for this tag handler.
 void release()
          Called on a Tag handler to release any state information.
 void setBodyContent(javax.servlet.jsp.tagext.BodyContent bodyContent)
          Set the bodyContent property.
 void setCaching(boolean caching)
          Sets whether we cache the template content from the body, or whether we recompile the template each time.
 void setPageContext(javax.servlet.jsp.PageContext pageContext)
          Set the current page context.
 void setParent(javax.servlet.jsp.tagext.Tag parent)
          Set the parent (closest enclosing tag handler) of this tag handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FreeMarkerTag

public FreeMarkerTag()
Method Detail

getCaching

public boolean getCaching()
Retrieve whether we're caching template content from the body, or whether we recompile the template each time.

Returns:
true if we're caching the template, otherwise false

setCaching

public void setCaching(boolean caching)
Sets whether we cache the template content from the body, or whether we recompile the template each time.

Parameters:
caching - true if we want to cache template content, otherwise false

getParent

public javax.servlet.jsp.tagext.Tag getParent()
Get the parent (closest enclosing tag handler) for this tag handler.

Specified by:
getParent in interface javax.servlet.jsp.tagext.Tag

setParent

public void setParent(javax.servlet.jsp.tagext.Tag parent)

Set the parent (closest enclosing tag handler) of this tag handler. Invoked by the JSP page implementation object prior to doStartTag().

This value is not reset by doEndTag() and must be explicitly reset by a page implementation.

Specified by:
setParent in interface javax.servlet.jsp.tagext.Tag
Parameters:
parent - The parent tag, or null.

doStartTag

public int doStartTag()
Process the start tag for this instance. This method is invoked by the JSP page implementation object.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag

setBodyContent

public void setBodyContent(javax.servlet.jsp.tagext.BodyContent bodyContent)
Set the bodyContent property.

Specified by:
setBodyContent in interface javax.servlet.jsp.tagext.BodyTag

setPageContext

public void setPageContext(javax.servlet.jsp.PageContext pageContext)

Set the current page context. This method is invoked by the JSP page implementation object prior to doStartTag().

This value is not reset by doEndTag() and must be explicitly reset by a page implementation if it changes between calls to doStartTag().

Specified by:
setPageContext in interface javax.servlet.jsp.tagext.Tag

doInitBody

public void doInitBody()
Prepare for evaluation of the body.

Specified by:
doInitBody in interface javax.servlet.jsp.tagext.BodyTag

doAfterBody

public int doAfterBody()
Process body (re)evaluation. This method is invoked by the JSP Page implementation object after every evaluation of the body into the BodyEvaluation object. The method is not invoked if there is no body evaluation.

Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag
Returns:
whether additional evaluations of the body are desired

release

public void release()
Called on a Tag handler to release any state information.

Specified by:
release in interface javax.servlet.jsp.tagext.Tag

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException

Process the end tag for this instance. This method is invoked by the JSP page implementation object on all Tag handlers.

This method will be called after returning from doStartTag(). The body of the action may or not have been evaluated, depending on the return value of doStartTag().

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Throws:
javax.servlet.jsp.JspException