This JSP example shows how to build a form that lets the user either check off multiple entries to delete from a product comparison list or delete all of the entries from the list. The ProductListHandler identifies each entry by its unique ID, which is stored in the id property.

Each product the user checks off on the form is added to entryIds, which stores the list of entry IDs for the products to remove from the product comparison list when calling ProductListHandler’s handleRemoveEntries method.

To remove all of the entries from the product comparison list, the user can simply click the “Remove all” submit button, which calls ProductListHandler’s handleClearAll method. (For more information on ProductListHandler’s handle methods, refer to Managing Product Comparison Lists.)

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

<dsp:form action="delete.jsp" method="POST">
<dsp:droplet name="ForEach">
  <dsp:param bean="ProductList.items" name="array"/>
  <dsp:param value="+product.displayName" name="sortProperties"/>

  <dsp:oparam name="empty">
    There are no items in your comparison list.

  <dsp:oparam name="outputStart">
    <b>Remove items from comparison list</b>

  <dsp:oparam name="output">
    <dsp:input bean="ProductListHandler.entryIds" paramvalue=""
    <dsp:valueof valueishtml="<%=true%>"

  <dsp:oparam name="outputEnd">
    <dsp:input bean="ProductListHandler.clearListSuccessURL" value="compare.jsp"
    <dsp:input bean="ProductListHandler.clearList" value="Remove
      all" type="submit"/>
    <dsp:input bean="ProductListHandler.removeProductSuccessURL"
              value="compare.jsp" type="hidden"/>
    <dsp:input bean="ProductListHandler.removeEntries" value="Remove selected
        items" type="submit"/>

loading table of contents...