Class ConditionalTagSupport

  • All Implemented Interfaces:
    IterationTag, JspTag, Tag, Serializable

    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:

    • Conditional processing of the action's body based on the returned value of the abstract method condition().
    • Storing the result of condition() as a Boolean object into a JSP scoped variable identified by attributes var and scope.
    Shawn Bayern
    See Also:
    Serialized Form
    • 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().

        a boolean representing the condition that a particular subclass uses to drive its conditional logic.
        JspTagException - on failure
      • release

        public void release()
        Releases any resources this ConditionalTagSupport may have (or inherit).
        Specified by:
        release in interface Tag
        release in class TagSupport
        See Also:
      • setVar

        public void setVar​(String var)
        Sets the 'var' attribute.
        var - Name of the exported scoped variable storing the result of condition().
      • setScope

        public void setScope​(String scope)
        Sets the 'scope' attribute.
        scope - Scope of the 'var' attribute