org.apache.taglibs.i18n
Class ConditionalTagSupport

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by org.apache.taglibs.i18n.ConditionalTagSupport
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.Tag
Direct Known Subclasses:
IfdefTag, IfndefTag

public abstract class ConditionalTagSupport
extends javax.servlet.jsp.tagext.BodyTagSupport

This class provides the base implementation for the ifdef and ifndef tags. Subclasses must provide an implementation of the shouldEvaluate() method.

Author:
Tim Dawson
See Also:
Serialized Form

Field Summary
protected static java.lang.String _tagname
           
 
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
ConditionalTagSupport()
           
 
Method Summary
 int doEndTag()
          Prints the body of the tag.
 int doStartTag()
          locates the bundle and tests whether the key has a value
 java.util.ResourceBundle getBundle()
           
protected  java.lang.String getValue()
          returns (if any) the value specified for the key in the bundle.
 void release()
          clears out the key for the next usage
 void setBundle(java.util.ResourceBundle aBundle)
          sets the bundle to an actual ResourceBundle object
if neither bundle or bundleRef are specified, uses the bundle most recently defined on the page by the i18n:bundle tag
 void setBundleRef(java.lang.String varName)
          sets the bundle based on a variable defined in the page
if neither bundle or bundleRef are specified, uses the first bundle defined on the page by the i18n:bundle tag
 void setKey(java.lang.String key)
          sets the key to use when looking up the value in the bundle
abstract  boolean shouldEvaluate()
          must be overridden by a subclass to return a boolean value
 
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, setId, 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

_tagname

protected static java.lang.String _tagname
Constructor Detail

ConditionalTagSupport

public ConditionalTagSupport()
Method Detail

setKey

public void setKey(java.lang.String key)
sets the key to use when looking up the value in the bundle


setBundleRef

public void setBundleRef(java.lang.String varName)
sets the bundle based on a variable defined in the page
if neither bundle or bundleRef are specified, uses the first bundle defined on the page by the i18n:bundle tag


setBundle

public void setBundle(java.util.ResourceBundle aBundle)
sets the bundle to an actual ResourceBundle object
if neither bundle or bundleRef are specified, uses the bundle most recently defined on the page by the i18n:bundle tag


getBundle

public java.util.ResourceBundle getBundle()
Returns:
the bundle to use

release

public void release()
clears out the key for the next usage

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

shouldEvaluate

public abstract boolean shouldEvaluate()
                                throws javax.servlet.jsp.JspException
must be overridden by a subclass to return a boolean value

Throws:
javax.servlet.jsp.JspException

getValue

protected java.lang.String getValue()
                             throws javax.servlet.jsp.JspException
returns (if any) the value specified for the key in the bundle. if no value is specified, traps the MissingResourceException and returns null

Throws:
javax.servlet.jsp.JspException

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
locates the bundle and tests whether the key has a value

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Prints the body of the tag.

Always return the flag for processing the rest of the JSP page.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
the flag for processing the rest of the JSP page.
Throws:
javax.servlet.jsp.JspException - if the writing out of the body fails.


Copyright ? 2000-2004 The Apache Software Foundation. All Rights Reserved.