javax.servlet.jsp.jstl.core
Class ConditionalTagSupport

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.jstl.core.ConditionalTagSupport
All Implemented Interfaces:
java.io.Serializable, IterationTag, JspTag, Tag

public abstract class ConditionalTagSupport
extends TagSupport

Abstract class that facilitates implementation of conditional actions where the boolean result is exposed as a JSP scoped variable. The boolean result may then be used as the test condition in a <c:when> action.

This base class provides support for:

Author:
Shawn Bayern
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
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()
          Base constructor to initialize local state.
 
Method Summary
protected abstract  boolean condition()
          Subclasses implement this method to compute the boolean result of the conditional action.
 int doStartTag()
          Includes its body if condition() evaluates to true.
 void release()
          Releases any resources this ConditionalTagSupport may have (or inherit).
 void setScope(java.lang.String scope)
          Sets the 'scope' attribute.
 void setVar(java.lang.String var)
          Sets the 'var' attribute.
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, doEndTag, 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
 

Constructor Detail

ConditionalTagSupport

public ConditionalTagSupport()
Base constructor to initialize local state. As with TagSupport, subclasses should not implement constructors with arguments, and no-argument constructors implemented by subclasses must call the superclass constructor.

Method Detail

condition

protected abstract boolean condition()
                              throws JspTagException

Subclasses implement this method to compute the boolean result of the conditional action. This method is invoked once per tag invocation by doStartTag().

Returns:
a boolean representing the condition that a particular subclass uses to drive its conditional logic.
Throws:
JspTagException

doStartTag

public int doStartTag()
               throws JspException
Includes its body if condition() evaluates to true.

Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class TagSupport
Returns:
SKIP_BODY
Throws:
JspException - if an error occurs while processing this tag
See Also:
Tag#doStartTag()

release

public void release()
Releases any resources this ConditionalTagSupport may have (or inherit).

Specified by:
release in interface Tag
Overrides:
release in class TagSupport
See Also:
Tag#release()

setVar

public void setVar(java.lang.String var)
Sets the 'var' attribute.

Parameters:
var - Name of the exported scoped variable storing the result of condition().

setScope

public void setScope(java.lang.String scope)
Sets the 'scope' attribute.

Parameters:
scope - Scope of the 'var' attribute


Submit a bug or feature

Copyright © 2009-2011, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms.

Generated on 10-February-2011 12:41