Customers can add items to any of their lists while they shop. In the Pioneer Cycling Store, we used the /atg/commerce/gifts/GiftlistFormHandler component in the product display page with an option for the customer to pick a list for the selected item.

The following code sample (from GiftlistGetItBox.jsp) demonstrates how to set the formHandler properties and how to add the selected product and quantity to a gift list:

<dsp:importbean bean="/atg/commerce/gifts/GiftlistFormHandler"/>
<dsp:importbean bean="/atg/userprofiling/Profile"/>

 <table cellpadding=0 cellspacing=0 border=0>
          <tr>
            <td class=box-top-store>Add to Gift List</td>
          </tr>
          <tr>
            <td class=box>

     <dsp:getvalueof id="form24" bean="/OriginatingRequest.requestURI"
          idtype="java.lang.String">
<dsp:form action="<%=form24%>" method="post">
     <input name="id" type="hidden" value='<dsp:valueof param="id"/>'>
     <input type="hidden" name="itemType" value="product">
     <input name="itemId" type="hidden" value='<dsp:valueof
                  param="Product.repositoryId"/>'>
     <dsp:input bean="GiftlistFormHandler.addItemToGiftlistSuccessURL"
          type="hidden" value="../user/lists.jsp"/>
     <dsp:input bean="GiftlistFormHandler.addItemToGiftlistErrorURL" type="hidden"
          value="../user/lists.jsp"/>
     <dsp:input bean="GiftlistFormHandler.productId"
          paramvalue="Product.repositoryId" type="hidden"/>

     <%/*Display any errors that have been generated during Cart operations: */%>
     <dsp:include page="../../common/DisplayGiftlistFormHandlerErrors.jsp"
          flush="true"></dsp:include>

     Add <dsp:input bean="GiftlistFormHandler.quantity" size="4" type="text"
              value="1"/>

     <dsp:select bean="GiftlistFormHandler.catalogRefIds">
     <dsp:droplet name="/atg/dynamo/droplet/ForEach">
       <dsp:param name="array" param="Product.childSKUs"/>
       <dsp:param name="elementName" value="sku"/>
       <dsp:param name="indexName" value="skuIndex"/>
       <dsp:oparam name="output">
     <dsp:getvalueof id="option59" param="sku.repositoryId"
          idtype="java.lang.String">
<dsp:option value="<%=option59%>"/>
</dsp:getvalueof><dsp:valueof param="sku.displayName"/>
       </dsp:oparam>
     </dsp:droplet>
     </dsp:select>
     <BR>
     to
     <dsp:select bean="GiftlistFormHandler.giftlistId">
       <dsp:getvalueof id="option73" bean="Profile.wishlist.id"
            idtype="java.lang.String">
<dsp:option value="<%=option73%>"/>
</dsp:getvalueof>My Wishlist
       <dsp:droplet name="/atg/dynamo/droplet/ForEach">
         <dsp:param bean="Profile.giftlists" name="array"/>
         <dsp:param name="elementName" value="giftlist"/>
         <dsp:oparam name="output">
         <dsp:getvalueof id="option83" param="giftlist.id"
              idtype="java.lang.String">
<dsp:option value="<%=option83%>"/>
</dsp:getvalueof><dsp:valueof param="giftlist.eventName">Undefined</dsp:valueof>
         </dsp:oparam>
        </dsp:droplet>
     </dsp:select>
     <dsp:input bean="GiftlistFormHandler.addItemToGiftlist" type="submit"
          value="I Want It"/>
    </dsp:form></dsp:getvalueof>

    </td>
  </tr>
</table>

The following screenshot is from a product page that demonstrates how the above code renders on the product page.

 
loading table of contents...