This JSP example shows how to display a simple product comparison table using the products in ProductList.items
and the table information in ProductList.tableInfo
(ProductList
’s referenced TableInfo
object).
Note that ProductComparisonList
(of which the ProductList
component is an instance) provides some convenience methods like sortProperties
and tableColumns
that call through to the referenced TableInfo
object. Consequently, the expression ProductList.tableColumns
is equivalent to the expression ProductList.tableInfo.tableColumns
.
Note: The use and behavior of the TableInfo
component is described in detail in the Implementing Sortable Tables chapter in the ATG Page Developer's Guide. Please refer to this manual for additional information on TableInfo
.
<dsp:importbean bean="/atg/dynamo/droplet/ForEach"/> <dsp:importbean bean="/atg/dynamo/droplet/BeanProperty"/> <dsp:importbean bean="/atg/commerce/catalog/comparison/ProductList"/> <dsp:droplet name="ForEach"> <dsp:param bean="ProductList.items" name="array"/> <dsp:param value="+product.displayName" name="sortProperties"/> <!-- Display table headings using TableInfo class --> <dsp:oparam name="outputStart"> <table border="1" cellpadding="5" cellspacing="1"> <dsp:droplet name="ForEach"> <dsp:param bean="ProductList.tableColumns" name="array"/> <dsp:param value="" name="sortProperties"/> <dsp:oparam name="output"> <dsp:valueof param="element.heading"/> </dsp:oparam> </dsp:droplet> </dsp:oparam> <!-- Display one table row for each item --> <dsp:oparam name="output"> <dsp:setvalue paramvalue="element" param="currentProduct"/> <tr> <dsp:droplet name="ForEach"> <dsp:param bean="ProductList.tableColumns" name="array"/> <dsp:param value="" name="sortProperties"/> <dsp:oparam name="output"> <td> <dsp:droplet name="BeanProperty"> <dsp:param param="currentProduct" name="bean"/> <dsp:param param="element.property" name="propertyName"/> <dsp:oparam name="output"> <dsp:valueof valueishtml="<%=true%>" param="propertyValue"/> </dsp:oparam> </dsp:droplet> </td> </dsp:oparam> </dsp:droplet> </tr> </dsp:oparam> <!-- Close the table --> <dsp:oparam name="outputEnd"> </table> </dsp:oparam> </dsp:droplet>