VehicleDocument.Vehicle[] 数组允许我们轻松地显示整个库存。现在,我们有一个准备好显示的对象数组。可以肯定的是,我们都习惯于在这些实例中使用 JavaBeans 和 NetUI 标签来显示数据列表。在 NetUI 标签中,会指定将显示的属性名,并通过反射从内部调用适当的访问器方法。因为值对象类似于 XMLBean 的属性,所以可以使用 VehicleDocument.Vehicles ,就像使用 JavaBean 那样显示它们。
在 JSP 上,只需要把 NetUI repeater 标签从调色板拖到编辑窗格中,就可以显示 Repeater 向导。在 Data Source 框中,先指定 pageFlow.inventory ,然后单击 Create (参见图 3 )。这个步骤是显示库存的过程中惟一必不可少的一步(参见清单 2 中生成的 repeater 代码块)。注意,容器的每一项都是一个 VehicleDocument.Vehicle 。尽管这个对象是 XML 实例文档的代表,但是可以通过名称轻松访问车辆的子元素。

图 3. 库存显示
把一个 NetUI repeater 标签从调色板拖拉到编辑窗格中,就可以显示 Repeater 向导。为一步式方法指定一个数据源,以显示库存。
Repeater 标签
清单 2. 使用数据 repeater 标签,这是显示库存过程中惟一必不可少的一步。
<netui-data:repeater dataSource=
"{pageFlow.inventory}">
<netui-data:repeaterHeader>
<table class="tablebody" border="1">
<tr class="tablehead" valign="top">
<th>Make</th>
<th>Model</th>
<th>Price</th>
<th>Status</th>
<th>Vin</th>
<th>Year</th>
</tr>
</netui-data:repeaterHeader>
<netui-data:repeaterItem>
<tr valign="top">
<td><netui:label value="{container.item.make}"
defaultValue=" "></netui:label></td>
<td><netui:label value="{container.item.model}"
defaultValue=" "></netui:label></td>
<td><netui:label value="{container.item.price}"
defaultValue=" "></netui:label></td>
<td><netui:label value="{container.item.status}"
defaultValue=" "></netui:label></td>
<td><netui:label value="{container.item.vin}"
defaultValue=" "></netui:label></td>
<td><netui:label value="{container.item.year}"
defaultValue=" "></netui:label></td>
</tr>
</netui-data:repeaterItem>
<netui-data:repeaterFooter></table>
</netui-data:repeaterFooter>
</netui-data:repeater>
