netui-data:choice Tag

<netui-data:choice> Tag

The contents of the <netui-data:choice> tag may be rendered conditionally based on the results returned by a <netui-data:choiceMethod> tag.

Syntax

<netui-data:choice
    [default="boolean_defaultChoice"]
    [value="string_value"] />

Description

The contents of the <netui-data:choice> tag may be rendered conditionally based on the results returned by a <netui-data: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 <netui-data: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.

Attributes

defaultBoolean. 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>.
 
RequiredSupports runtime expression evaluationData bindable
NoNoNo

valueA 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.
 
RequiredSupports runtime expression evaluationData bindable
NoNoYes

Sample

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

Related Topics

<netui-data:choice> Tag Sample

<netui-data:choiceMethod> Tag

Presenting Complex Data Sets in JSPs (Repeater Tags section)