This JSP example shows how to build a form from a search results list and let the user check off multiple products on the form and add them to a product comparison list.

Each product the user checks off on the form is added to productIdList, which stores the list of repository IDs for the products to add to the comparison list when calling either ProductListHandler’s handleAddProductList method or handleAddProductListAllSkus method. In this example, the handleAddProductList method is called. (For more information on ProductListHandler’s handle methods, refer to Managing Product Comparison Lists.)

<dsp:importbean bean="/atg/commerce/catalog/comparison/ProductListHandler"/>
<dsp:importbean bean="/atg/commerce/catalog/SearchFormHandler"/>

<dsp:form action="compare.jsp" method="POST">
<dsp:droplet name="ForEach">
  <dsp:param bean="SearchFormHandler.searchResults" name="array"/>
  <dsp:param value="+displayName" name="sortProperties"/>

  <dsp:oparam name="outputStart">
    <table border=0 cellpadding=0 cellspacing=0>
  </dsp:oparam>

  <dsp:oparam name="output">
    <tr>
    <td>
      <dsp:input bean="ProductListHandler.productIdList"
           paramvalue="element.repositoryId" type="checkbox"/>
      <dsp:valueof param="element.displayName"/> - <dsp:valueof
           param="element.description"/>
    </td>
    </tr>
  </dsp:oparam>

  <dsp:oparam name="outputEnd">
    </table></br>
    <dsp:input bean="ProductListHandler.addProductList" value="Add to list"
         type="submit"/>
  </dsp:oparam>

</dsp:droplet>
</dsp:form>
 
loading table of contents...