The contents of the <netui-data:choice> tag may be rendered conditionally based on the results returned by a <netui-data:choiceMethod> tag.
<netui-data:choice
[default="boolean_defaultChoice"]
[value="string_value"] />
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.
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>
[BEA_HOME]\weblogic81\samples\workshop\SamplesApp\WebApp\tagSamples\netui_databinding\choice
<netui-data:choice> Tag Sample
Presenting Complex Data Sets in JSPs (Repeater Tags section)