Choice Class
- public class Choice
extends RepeaterComponent
A tag that when nested in a RepeaterItem allows its body to be rendered
conditionally. The Choice tag must be used together with the ChoiceMethod
tag in order to achieve conditional rendering of the body of a particular
Choice tag. A single ChoiceMethod and one or more Choice tags should be
nested within a RepeaterItem. The RepeaterItem then uses the ChoiceMethod
to invoke a decision method that returns the value. The return value is then compared
against the value attribute on each Choice tag in order to select the
Choice whose body should be rendered. If no match is found but one of the
Choice tags has its default attribute set, this "default"
Choice will be rendered.
| Attribute Descriptions |
| Attribute | Required | Runtime Expression Evaluation | Data Bindable |
| default | No | No | No |
A boolean that if true will render this Choice's body if no Choice's value matches the result of the ChoiceMethod. |
| value | No | No | Yes |
A String value that will be matched against the value returned from invoking the ChoiceMethod. |
Related Topics
<netui-data:choice> Tag Sample
ChoiceMethod
Presenting Complex Data Sets in JSPs (Repeater Tags section)
-
Hierarchy
-
Object
TagSupport
BodyTagSupport
AbstractBaseTag
StructuredBaseTag
RepeaterComponent
Choice
-
All Implemented Interfaces
-
BodyTag, IterationTag, Serializable, Tag
Fields from com.bea.wlw.netui.tags.AbstractBaseTag |
ATTR_GENERAL, ATTR_GENERAL_EXPRESSION, ATTR_JAVASCRIPT, ATTR_STYLE, CLASS, ID, JAVASCRIPT_STATUS, NAME, NETUI_UNIQUE_CNT, ONCLICK, ONDBLCLICK, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, STYLE, TABINDEX |
Methods from com.bea.wlw.netui.tags.databinding.base.StructuredBaseTag |
addContent, doEndTag, doStartTag, getContent, getCurrentRenderState, getValidContainerType, localRelease, prepare, renderEndTag, verifyAttributes, verifyStructure |
Methods from com.bea.wlw.netui.tags.AbstractBaseTag |
addTagIdMapping, evaluateAttributeToString, filter, filter, getJavaScriptUtils, getNearestForm, getScriptReporter, getUserLocale, localRelease, registerTagError, release, renderAttribute, rewriteName, write |
Methods from javax.servlet.jsp.tagext.TagSupport |
doAfterBody, doEndTag, doStartTag, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue |
Choice
public Choice()
doAfterBody() Method
public int doAfterBody()
Handle the content that may have been rendered in the body by adding it to
the RepeaterItem's content.
-
Overrides
-
RepeaterComponent.doAfterBody()
Returns
- SKIP_BODY
getActualValue() Method
public Object getActualValue()
getCurrentRenderState() Method
protected int getCurrentRenderState()
Get the current render state of this tag's RepeaterItem parent.
-
Overrides
-
RepeaterComponent.getCurrentRenderState()
Returns
- the render state of the parent
RepeaterItem
getDefault() Method
public boolean getDefault()
Get the boolean value of the default attribute.
Returns
true if this Choice tag is the default choice in a
Repeater body; false otherwise
getTagName() Method
public String getTagName()
Get the name of this tag. This is used to identify the type of this tag
for reporting tag errors.
-
Overrides
-
AbstractBaseTag.getTagName()
Returns
- a constant String representing the name of this tag.
getValidContainerType() Method
protected Class getValidContainerType()
Get the valid container type of this tag, the RepeaterItem.
-
Overrides
-
RepeaterComponent.getValidContainerType()
Returns
- the valid container type
getValue() Method
public String getValue()
Get the String value that will be checked for a match in the ChoiceMethod.
Returns
- the value that should be matched or
null if unset
localRelease() Method
protected void localRelease()
Reset all of the fields of this tag.
-
Overrides
-
RepeaterComponent.localRelease()
prepare() Method
protected void prepare()
Prepare data that is provided to subclasses of this tag.
-
Overrides
-
RepeaterComponent.prepare()
renderStartTag(int) Method
public int renderStartTag(int state)
throws JspException
Conditionally render the body of this tag.
The body is rendered if the RepeaterItem.shouldRender(Object, boolean)
call returns true and the RepeaterItem is in its RepeaterItem.RENDER state. Otherwise,
the body is skipped.
-
Overrides
- StructuredBaseTag.renderStartTag(int)
Parameters
-
state
- the
tag's current render state
Returns
- SKIP_BODY unless the repeater item should render; then return EVAL_BODY_BUFFERED
Exceptions
-
JspException
reportErrors() Method
protected void reportErrors()
throws JspException
Description copied from AbstractBaseTag.reportErrors()
This will report an expression error.
-
Overrides
-
AbstractBaseTag.reportErrors()
Exceptions
-
JspException
setDefault(boolean) Method
public void setDefault(boolean defaultItem)
Sets a boolean value that, if true will mark a Choice tag as
the "default" Choice if no other Choices match the value returned in
invoking the ChoiceMethod.
Parameters
-
defaultItem
- a boolean that denotes this item as the "default" to render
setValue(String) Method
public void setValue(String value)
Set a String value that is used by the RepeaterItem to select this Choice
tag if this value is returned by the ChoiceMethod. The RepeaterItem
selects a Choice based on the value returned by running the ChoiceMethod
tag; this value is compared against the value attribute here. If
a match is found in performing this comparison, the matching Choice tag is
rendered in the RepeaterItem.
Parameters
-
value
- the value that should be matched in order to render this Choice
toString() Method
public String toString()
Get a debugging String that represents a PadContext.
-
Overrides
-
Object.toString()
Returns
- a String representation of the PadContext