- java.lang.Object
-
- jakarta.servlet.jsp.tagext.TagSupport
-
- jakarta.servlet.jsp.jstl.core.ConditionalTagSupport
-
- All Implemented Interfaces:
jakarta.servlet.jsp.tagext.IterationTag
,jakarta.servlet.jsp.tagext.JspTag
,jakarta.servlet.jsp.tagext.Tag
,Serializable
public abstract class ConditionalTagSupport extends jakarta.servlet.jsp.tagext.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 aBoolean
object into a JSP scoped variable identified by attributesvar
andscope
.
- Author:
- Shawn Bayern
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ConditionalTagSupport()
Base constructor to initialize local state.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract boolean
condition()
Subclasses implement this method to compute the boolean result of the conditional action.int
doStartTag()
Includes its body ifcondition()
evaluates to true.void
release()
Releases any resources this ConditionalTagSupport may have (or inherit).void
setScope(String scope)
Sets the 'scope' attribute.void
setVar(String var)
Sets the 'var' attribute.
-
-
-
Method Detail
-
condition
protected abstract boolean condition() throws jakarta.servlet.jsp.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:
jakarta.servlet.jsp.JspTagException
- on failure
-
doStartTag
public int doStartTag() throws jakarta.servlet.jsp.JspException
Includes its body ifcondition()
evaluates to true.- Specified by:
doStartTag
in interfacejakarta.servlet.jsp.tagext.Tag
- Overrides:
doStartTag
in classjakarta.servlet.jsp.tagext.TagSupport
- Throws:
jakarta.servlet.jsp.JspException
-
release
public void release()
Releases any resources this ConditionalTagSupport may have (or inherit).- Specified by:
release
in interfacejakarta.servlet.jsp.tagext.Tag
- Overrides:
release
in classjakarta.servlet.jsp.tagext.TagSupport
-
setVar
public void setVar(String var)
Sets the 'var' attribute.- Parameters:
var
- Name of the exported scoped variable storing the result ofcondition()
.
-
setScope
public void setScope(String scope)
Sets the 'scope' attribute.- Parameters:
scope
- Scope of the 'var' attribute
-
-