Choice Class

com.bea.wlw.netui.tags.databinding.repeater.choice
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
AttributeRequiredRuntime Expression EvaluationData Bindable
defaultNoNoNo
A boolean that if true will render this Choice's body if no Choice's value matches the result of the ChoiceMethod.
valueNoNoYes
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

Field Summary

   
Fields from  com.bea.wlw.netui.tags.databinding.repeater.RepeaterComponent
debug
 
Fields from  com.bea.wlw.netui.tags.databinding.base.StructuredBaseTag
EMPTY_STRING
 
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
 
Fields from  javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields from  javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 

Constructor Summary

Choice()

 

Method Summary

public int
doAfterBody()
Handle the content that may have been rendered in the body by adding it to the RepeaterItem's content.
public Object
getActualValue()
protected int
getCurrentRenderState()
Get the current render state of this tag's RepeaterItem parent.
public boolean
getDefault()
Get the boolean value of the default attribute.
public String
getTagName()
Get the name of this tag.
protected Class
getValidContainerType()
Get the valid container type of this tag, the RepeaterItem.
public String
getValue()
Get the String value that will be checked for a match in the ChoiceMethod.
protected void
localRelease()
Reset all of the fields of this tag.
protected void
prepare()
Prepare data that is provided to subclasses of this tag.
public int
renderStartTag(int state)
Conditionally render the body of this tag.
protected void
reportErrors()
This will report an expression error.
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.
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.
public String
toString()
Get a debugging String that represents a PadContext.
 
Methods from  com.bea.wlw.netui.tags.databinding.repeater.RepeaterComponent
getRepeater, renderEndTag
 
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.BodyTagSupport
doAfterBody, doEndTag, doInitBody, doStartTag, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods from  javax.servlet.jsp.tagext.TagSupport
doAfterBody, doEndTag, doStartTag, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
   
Methods from interface javax.servlet.jsp.tagext.BodyTag
doInitBody, setBodyContent
 
Methods from interface javax.servlet.jsp.tagext.IterationTag
doAfterBody
 
Methods from interface javax.servlet.jsp.tagext.Tag
doEndTag, doStartTag, getParent, release, setPageContext, setParent
 

Constructor Detail

Choice

public Choice()
 

Method Detail

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