# Items.jsp Sample

This topic inludes the source code for the Items.jsp Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui_databinding/choice/

## Sample Source Code

`01 <!--Generated by Weblogic Workshop--> 02 <%@ page language="java" contentType="text/html;charset=UTF-8"%> 03 <%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%> 04 <%@ taglib uri="netui-tags-html.tld" prefix="netui"%> 05 <%@ taglib uri="netui-tags-template.tld" prefix="netui-template"%> 06 <html> 07 <head> 08 <title> 09 items.jsp 10 </title> 11 <link href="../../../resources/css/style.css" type="text/css" rel="stylesheet"/> 12 </head> 13 <body> 14 <jsp:include page="/resources/jsp/header.jsp"/> 15 16 <blockquote> 17 <%-- 18 The repeater element is used to render complex data types (Arrays, Maps, RowSets, etc.) 19 as HTML. 20 In this case, the repeater element is databound to a RowSet and renders that 21 RowSet as an HTML table. (The repeater element is bound to a data set via its dataSource 22 attribute.) 23 --%> 24 <netui-data:repeater dataSource="{pageFlow.allRows}" defaultText="no records"> 25 <netui-data:repeaterHeader> 26 <table class="table" border="1"> 27 <thead><tr><td colspan="4"><h2>Items</h2></td></tr></thead> 28 <tr class="tablehead"> 29 <td>ID Number</td> 30 <td>Name</td> 31 <td>Quantity Available</td> 32 <td>Price</td> 33 </tr> 34 </netui-data:repeaterHeader> 35 <%-- 36 The repeaterItem element renders a single HTML table row for each row 37 within the RowSet. 38 The RowSet as a whole is referenced by the XScript expression 'container'. 39 The individual rows of the RowSet are referenced by the expression 'container.item'. 40 The fields of an individual row are referenced by expression 'container.item.[fieldname]'. 41 42 Each row is rendered in one of two different ways by the use of the 43 choiceMethod and choice elements. Before the repeaterItem renders an individual row, 44 the page flow method isItemOnSale is consulted: if that method returns true, the row is 45 rendered with a red background color; if it returns false, the row is rendered 46 with a white background color. 47 --%> 48 <netui-data:repeaterItem> 49 <netui-data:choiceMethod object="{pageFlow}" method="isItemOnSale"> 50 <netui-data:methodParameter value="{container.item.quantityavailable}"/> 51 </netui-data:choiceMethod> 52 <netui-data:choice value="true"> 53 <tr class="row" bgcolor="#FF9999"> 54 <td><netui:label value="{container.item.itemnumber}"/></td> 55 <td><netui:label value="{container.item.itemname}"/></td> 56 <td><netui:label value="{container.item.quantityavailable}"/></td> 57 <td><netui:label value="{container.item.price}"/> Clearance Item</td> 58 </tr> 59 </netui-data:choice> 60 <netui-data:choice value="false"> 61 <tr class="row"> 62 <td><netui:label value="{container.item.itemnumber}"/></td> 63 <td><netui:label value="{container.item.itemname}"/></td> 64 <td><netui:label value="{container.item.quantityavailable}"/></td> 65 <td><netui:label value="{container.item.price}"/></td> 66 </tr> 67 </netui-data:choice> 68 </netui-data:repeaterItem> 69 <netui-data:repeaterFooter> 70 </table> 71 </netui-data:repeaterFooter> 72 </netui-data:repeater> 73 74 <hr width="90%"> 75 <p><netui:anchor action="begin.do">Return to choiceTag Samples Home</netui:anchor></p> 76 <p>&nbsp;</p> 77 </blockquote> 78 </body> 79 </html>`