Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.base.tags
Class CacheTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by com.jivesoftware.base.tags.CacheTag
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 CacheTag
extends javax.servlet.jsp.tagext.BodyTagSupport

A simple tag that caches all content between the <cache> tags. The content can later be retrieved by id using an empty cache tag. The scope of the cache is just the request, so this cache is only good when you have exact duplicated blocks of JSP code or HTML on one page.

Usage:

Then later will print out the same content from above.

Attributes:

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id
 
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
CacheTag()
           
 
Method Summary
 int doAfterBody()
          Always returns SKIP_BODY.
 int doEndTag()
          Get the body content and store it in the cache (if it exists) and also write out the content.
 int doStartTag()
          If the value of the id is found in the cache, write it out and return SKIP_BODY.
 javax.servlet.jsp.tagext.BodyContent getBodyContent()
          Returns the body content of this tag.
 javax.servlet.jsp.tagext.Tag getParent()
          Returns the parent tag of this Tag.
 void release()
           
 void setBodyContent(javax.servlet.jsp.tagext.BodyContent bodyContent)
          Sets the body content between the start and end tags.
 void setPageContext(javax.servlet.jsp.PageContext pageContext)
          Sets the page context of this Tag.
 void setParent(javax.servlet.jsp.tagext.Tag parentTag)
          Sets the parent tag of this tag.
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doInitBody, getPreviousOut
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getValue, getValues, removeValue, setId, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheTag

public CacheTag()
Method Detail

setPageContext

public void setPageContext(javax.servlet.jsp.PageContext pageContext)
Sets the page context of this Tag.

Specified by:
setPageContext in interface javax.servlet.jsp.tagext.Tag
Overrides:
setPageContext in class javax.servlet.jsp.tagext.TagSupport
Parameters:
pageContext - the page context for this Tag.

getParent

public javax.servlet.jsp.tagext.Tag getParent()
Returns the parent tag of this Tag.

Specified by:
getParent in interface javax.servlet.jsp.tagext.Tag
Overrides:
getParent in class javax.servlet.jsp.tagext.TagSupport
Returns:
the parent tag of this Tag.

setParent

public void setParent(javax.servlet.jsp.tagext.Tag parentTag)
Sets the parent tag of this tag.

Specified by:
setParent in interface javax.servlet.jsp.tagext.Tag
Overrides:
setParent in class javax.servlet.jsp.tagext.TagSupport
Parameters:
parentTag - the parent tag of this tag.

getBodyContent

public javax.servlet.jsp.tagext.BodyContent getBodyContent()
Returns the body content of this tag.

Overrides:
getBodyContent in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
the body content of this tag.

setBodyContent

public void setBodyContent(javax.servlet.jsp.tagext.BodyContent bodyContent)
Sets the body content between the start and end tags.

Specified by:
setBodyContent in interface javax.servlet.jsp.tagext.BodyTag
Overrides:
setBodyContent in class javax.servlet.jsp.tagext.BodyTagSupport
Parameters:
bodyContent - the body content between the start and end tags.

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
If the value of the id is found in the cache, write it out and return SKIP_BODY. Otherwise, check if the tag body has been collected. If not, return EVAL_BODY_BUFFERED, otherwise return SKIP_BODY.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
SKIP_BODY if the id is found in the cache or if the body has already been collected, otherwise return EVAL_BODY_BUFFERED so the body content is gathered.
Throws:
javax.servlet.jsp.JspException - if there is a problem writing the content out from cache.

doAfterBody

public int doAfterBody()
Always returns SKIP_BODY.

Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag
Overrides:
doAfterBody in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
returns SKIP_BODY always.

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Get the body content and store it in the cache (if it exists) and also write out the content.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
EVAL_PAGE always.
Throws:
javax.servlet.jsp.JspException - if there is a problem writing the body content.

release

public void release()
Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class javax.servlet.jsp.tagext.BodyTagSupport

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.