BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.

com.bea.wlw.netui.tags.databinding.repeater.choice
Class Choice

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by com.bea.wlw.netui.tags.AbstractBaseTag
              extended by com.bea.wlw.netui.tags.databinding.base.StructuredBaseTag
                  extended by com.bea.wlw.netui.tags.databinding.repeater.RepeaterComponent
                      extended by com.bea.wlw.netui.tags.databinding.repeater.choice.Choice
All Implemented Interfaces:
HtmlConstants, Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

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.

See Also:
ChoiceMethod, Serialized Form
Example:

In the following example, the <netui-data:choiceMethod> tag calls the isItemsOnSale method, which returns a boolean value. If the return value is true, then the contents of the <netui-data:choice value="true"> tag are rendered; if the return value is false, then the contents of the <netui-data:choice value="false"> tag are rendered.

          <netui-data:repeaterItem>
             <netui-data:choiceMethod object="{pageFlow}" method="isItemOnSale">
                 <netui-data:methodParameter value="{container.item.quantityavailable}"/>
             </netui-data:choiceMethod>
             <netui-data:choice value="true">
                 <tr class="row" bgcolor="#FF9999">
                     <td><netui:label value="{container.item.itemnumber}"/></td>
                     <td><netui:label value="{container.item.itemname}"/></td>
                     <td><netui:label value="{container.item.quantityavailable}"/></td>
                     <td><netui:label value="{container.item.price}"/> Clearance Item</td>
                  </tr>
             </netui-data:choice>
             <netui-data:choice value="false">
                 <tr class="row">
                     <td><netui:label value="{container.item.itemnumber}"/></td>
                     <td><netui:label value="{container.item.itemname}"/></td>
                     <td><netui:label value="{container.item.quantityavailable}"/></td>
                     <td><netui:label value="{container.item.price}"/></td>
                 </tr>
             </netui-data:choice>
          </netui-data:repeaterItem>

Sample Code

[BEA_HOME]\weblogic81\samples\workshop\SamplesApp\WebApp\tagSamples\netui_databinding\choice

Beadoc.see:
<netui-data:choice> Tag Sample, Presenting Complex Data Sets in JSPs (Repeater Tags section)
Beadoc.tagdescription:
The contents of the <netui-data:choice> tag may be rendered conditionally based on the results returned by a ChoiceMethod tag.

The <netui-data:choice> tag must be used together with the <netui-data:choiceMethod> tag in order to achieve conditional rendering of the body of a particular <netui-data:choice> tag. A single <netui-data:choiceMethod> and one or more <netui-data:choice> tags should be nested within a RepeaterItem tag.

          <netui-data:repeaterItem>
              <netui-data:choiceMethod object="{pageFlow}" method="myChoiceMethod"/>
              <netui-data:choice value="case1">
                   <!-- 
                   Content to render if myChoiceMethod returns "case1"
                   -->
              </netui-data:choice>
              <netui-data:choice value="case2">
                   <!-- 
                   Content to render if myChoiceMethod returns "case2"
                   -->
              </netui-data:choice>
              <netui-data:choice value="default">
                   <!-- 
                   Content to render if myChoiceMethod neither "case1" nor "case2".
                   -->
              </netui-data:choice>
          </netui-data:repeaterItem>
For each item in the <netui-data:repeaterItem> tag's data set, the <netui-data:choiceMethod> invokes a decision method that returns a value. The return value is then compared against the value attribute on each <netui-data:choice> tag in order to select the <netui-data:choice> whose body should be rendered. If no match is found but one of the <netui-data:choice> tags has its default attribute set to true, this "default" <netui-data:choice> will be rendered.

Field Summary
 
Fields inherited from class com.bea.wlw.netui.tags.databinding.base.StructuredBaseTag
EMPTY_STRING
 
Fields inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
ATTR_GENERAL, ATTR_GENERAL_EXPRESSION, ATTR_JAVASCRIPT, ATTR_STYLE, JAVASCRIPT_STATUS, NETUI_UNIQUE_CNT
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface com.bea.wlw.netui.tags.html.HtmlConstants
ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, HEIGHT, HREF, HREFLANG, HSPACE, HTML, ID, IMAGE, INPUT, INPUT_BUTTON, INPUT_CHECKBOX, INPUT_FILE, INPUT_HIDDEN, INPUT_IMAGE, INPUT_PASSWORD, INPUT_RADIO, INPUT_RESET, INPUT_SUBMIT, INPUT_TEXT, ISMAP, LABEL, LANG, LINK, LONGDESC, MAXLENGTH, METHOD, NAME, ONBLUR, ONCHANGE, ONCLICK, ONDBLCLICK, ONFOCUS, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONLOAD, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, ONRESET, ONSELECT, ONSUBMIT, ONUNLOAD, OPTION, READONLY, REL, REV, ROWS, RULES, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TD, TEXT, TEXTAREA, TITLE, TR, TYPE, USEMAP, VALIGN, VALUE, VLINK, VSPACE, WIDTH
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
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
Choice()
           
 
Method Summary
 int doAfterBody()
          Handle the content that may have been rendered in the body by adding it to the RepeaterItem's content.
 Object getActualValue()
           
protected  int getCurrentRenderState()
          Get the current render state of this tag's RepeaterItem parent.
 boolean getDefault()
          Get the boolean value of the default attribute.
 String getTagName()
          Get the name of this tag.
protected  Class getValidContainerType()
          Get the valid container type of this tag, the RepeaterItem.
 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.
 int renderStartTag(int state)
          Conditionally render the body of this tag.
protected  void reportErrors()
          This will report an expression error.
 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.
 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.
 String toString()
          Get a debugging String that represents a PadContext.
 
Methods inherited from class com.bea.wlw.netui.tags.databinding.repeater.RepeaterComponent
getRepeater, renderEndTag
 
Methods inherited from class com.bea.wlw.netui.tags.databinding.base.StructuredBaseTag
addContent, doEndTag, doStartTag, getContent, verifyAttributes, verifyStructure
 
Methods inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
addTagIdMapping, containsExpression, evaluateAttributeToString, evaluateExpression, filter, filter, formatErrorString, formatString, getAttribute, getErrorsReport, getExpressionEvaluator, getJavaScriptUtils, getNearestForm, getNextId, getQualifiedBundleName, getScriptReporter, getUserLocale, hasErrors, isExpression, prepForRendering, registerAttribute, registerError, registerTagError, release, removeAttribute, renderAttribute, renderAttributes, rewriteName, setPageContext, updateExpression, write
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setParent
 

Constructor Detail

Choice

public Choice()
Method Detail

getTagName

public String getTagName()
Get the name of this tag. This is used to identify the type of this tag for reporting tag errors.

Specified by:
getTagName in class AbstractBaseTag
Returns:
a constant String representing the name of this tag.

setDefault

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
Beadoc.attributedescription:
Boolean. Marks a <netui-data:choice> tag as the "default" <netui-data:choice> if no other <netui-data:choice> tags match the value returned by the <netui-data:choiceMethod>.
Beadoc.attributesyntaxvalue:
boolean_defaultChoice
Beadoc.databindable:
false

getDefault

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

setValue

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
Beadoc.attributedescription:
A String value to match against the value returned by the <netui-data:choiceMethod> tag. If a match is found in performing this comparison, the matching <netui-data:choice> tag is rendered.
Beadoc.attributesyntaxvalue:
string_value
Beadoc.databindable:
true

getValue

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

getActualValue

public Object getActualValue()

renderStartTag

public int renderStartTag(int state)
                   throws javax.servlet.jsp.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.

Specified by:
renderStartTag in class StructuredBaseTag
Parameters:
state - the Repeater tag's current render state
Returns:
SKIP_BODY unless the repeater item should render; then return EVAL_BODY_BUFFERED
Throws:
javax.servlet.jsp.JspException

reportErrors

protected void reportErrors()
                     throws javax.servlet.jsp.JspException
Description copied from class: AbstractBaseTag
This will report an expression error.

Overrides:
reportErrors in class AbstractBaseTag
Throws:
javax.servlet.jsp.JspException

doAfterBody

public int doAfterBody()
Handle the content that may have been rendered in the body by adding it to the RepeaterItem's content.

Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag
Overrides:
doAfterBody in class RepeaterComponent
Returns:
SKIP_BODY

localRelease

protected void localRelease()
Reset all of the fields of this tag.

Overrides:
localRelease in class RepeaterComponent

toString

public String toString()
Get a debugging String that represents a PadContext.

Overrides:
toString in class Object
Returns:
a String representation of the PadContext

getCurrentRenderState

protected int getCurrentRenderState()
Get the current render state of this tag's RepeaterItem parent.

Overrides:
getCurrentRenderState in class RepeaterComponent
Returns:
the render state of the parent RepeaterItem

getValidContainerType

protected Class getValidContainerType()
Get the valid container type of this tag, the RepeaterItem.

Overrides:
getValidContainerType in class RepeaterComponent
Returns:
the valid container type

prepare

protected void prepare()
Prepare data that is provided to subclasses of this tag.

Overrides:
prepare in class RepeaterComponent

BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.