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 the handleRemoveEntries method in ProductListHandler.

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>

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

  <dsp:oparam name="output">
    <dsp:input bean="ProductListHandler.entryIds" paramvalue="element.id"
               type="checkbox"/>
    <dsp:valueof valueishtml="<%=true%>"
         param="element.product.displayName"/></br>
  </dsp:oparam>

  <dsp:oparam name="outputEnd">
    </blockquote>
    <br>
    <dsp:input bean="ProductListHandler.clearListSuccessURL" value="compare.jsp"
               type="hidden"/>
    <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"/>
  </dsp:oparam>

</dsp:droplet>
</dsp:form>

Copyright © 1997, 2019 Oracle and/or its affiliates. All rights reserved. Legal Notices