All Pioneer Store registered customers can create and update an unlimited number of gift lists that are added to their profiles. We used the standard gift lists provided by ATG Consumer Commerce that extend the customer’s profile in the Profile Repository. Again, we used userProfile.xml. Refer to the Configuring Merchandising Services chapter in the ATG Commerce Programming Guide for more information on how gift lists are created for each user.

The GiftlistFormHandler manages wish lists and gift lists. The following wish list and saved gift lists code sample shows how the Pioneer Cycling store displays wish lists and gift lists and the items in each. lists.jsp. This sample has been edited for clarity. See <ATG2007.3dir>/PioneerCyclingJSP/j2ee-apps/pioneer/web-app/en/user/lists.jsp for the complete file.

<dsp:form action="lists.jsp" method="post">
<p>
<span class=storebig>My Lists</span><p>
<span class=help>Lists allow you to save products you want for later, and share
your giftlists with friends.</span>
<p>

<!-- First display the wishlist -->

<dsp:setvalue beanvalue="Profile.wishlist" param="wishlist"/>
<dsp:setvalue paramvalue="wishlist.giftlistItems" param="items"/>
<dsp:setvalue paramvalue="wishlist.id" param="giftlistId"/>
<dsp:input bean="GiftlistFormHandler.updateGiftlistItemsSuccessURL" type="hidden"
           value="./lists.jsp"/>
<dsp:input bean="GiftlistFormHandler.updateGiftlistItemsErrorURL" type="hidden"
           value="./lists.jsp"/>
<dsp:input bean="GiftlistFormHandler.giftlistId" paramvalue="giftlistId"
           type="hidden"/>
<dsp:droplet name="IsEmpty">
  <dsp:param name="value" param="items"/>
  <dsp:oparam name="false">
    <dsp:droplet name="/atg/dynamo/droplet/ForEach">
      <dsp:param name="array" param="items"/>

      <dsp:oparam name="output">
        <tr valign=top>
        <td><input name='<dsp:valueof param="element.id"/>' size="2" type="text"
                   value='<dsp:valueof param="element.quantityDesired"/>'></td>
        <td></td>
        <td>
          <dsp:droplet name="/atg/commerce/catalog/ProductLookup">
            <dsp:param name="id" param="element.productId"/>
            <dsp:param name="elementName" value="product"/>
            <dsp:oparam name="output">
              <b>

              <dsp:getvalueof id="templateUrl" idtype="String"
                   param="product.template.url">
              <dsp:a page="<%=templateUrl%>">
                <dsp:param name="id" param="id"/>
                <dsp:param name="navAction" value="jump"/>
                <dsp:droplet name="/atg/commerce/catalog/SKULookup">
              <dsp:param name="id" param="element.catalogRefId"/>
              <dsp:param name="elementName" value="giftSku"/>
              <dsp:oparam name="output"><dsp:valueof
                   param="giftSku.displayName"/></dsp:oparam>
                </dsp:droplet>
              </dsp:a>
              </dsp:getvalueof>
              </b>
            </dsp:oparam>
          </dsp:droplet>
        </td>
      </dsp:oparam>
      <dsp:oparam name="outputEnd">
           <dsp:input bean="GiftlistFormHandler.updateGiftlistItems" type="submit"
                value="Update wishlist quantities"/>
      </dsp:oparam>
   </dsp:droplet>
   </dsp:oparam>

  <dsp:oparam name="true">
  <b>Your wishlist is empty</b>
  </dsp:oparam>
</dsp:droplet>
</dsp:form>

<!-- Next display each giftlist -->

<dsp:droplet name="IsEmpty">
  <dsp:param bean="Profile.giftlists" name="value"/>
  <dsp:oparam name="false">

  <dsp:droplet name="/atg/dynamo/droplet/ForEach">
  <dsp:param bean="Profile.giftlists" name="array"/>
  <dsp:oparam name="output">

  <blockquote>
  <dsp:form action="lists.jsp" method="post">
  <table cellspacing=2 cellpadding=0 border=0  width=75%>
  <!-- Display giftlist name -->
    <tr><td colspan=10 class=box-top-viewmy>
    <dsp:valueof param="element.eventName"/>
    </td>
  </tr>

  <!-- Display giftlist items if any -->
  <dsp:setvalue paramvalue="element.giftlistItems" param="items"/>
  <dsp:setvalue paramvalue="element.id" param="giftlistId"/>
  <dsp:setvalue paramvalue="element.eventName" param="listName"/>

  <dsp:input bean="GiftlistFormHandler.updateGiftlistItemsSuccessURL"
       type="hidden" value="./lists.jsp"/>
  <dsp:input bean="GiftlistFormHandler.updateGiftlistItemsErrorURL" type="hidden"
       value="./lists.jsp"/>
  <dsp:input bean="GiftlistFormHandler.giftlistId" paramvalue="giftlistId"
       type="hidden"/>

  <dsp:droplet name="IsEmpty">
    <dsp:param name="value" param="items"/>
    <dsp:oparam name="false">

  <!-- Display giftlist items if any -->
    </dsp:oparam>
    <dsp:oparam name="true">
    </dsp:oparam>
  </dsp:droplet>
 </dsp:form>
<!--* Finally, check if customer is registered. If so allow them to create a
     * new giftlist using GiftlistFormHandler.createGiftlist. -->

The following screenshot shows how the above code sample displays the customer’s wish list, gift list(s) and their contents.

Creating Gift Lists

In the above screenshot, one option for registered customers is to create and edit gift lists. The following code sample shows how to test for registered customers and to display the box to create a new list:

lists.jsp

<dsp:droplet name="/atg/dynamo/droplet/Switch">
 <dsp:param bean="Profile.transient" name="value"/>
 <dsp:oparam name="false">
  <blockquote>
  <table cellspacing=0 cellpadding=0 border=0 width=75%>
   <tr><td colspan=6 class=box-top-viewmy>Make a new gift list</td></tr>
   <tr><td colspan=6 class=box>
    <dsp:form action="lists_new.jsp" method="POST">
    <dsp:input bean="GiftlistFormHandler.createGiftlistSuccessURL"
               type="hidden" value="./lists_new.jsp"/>
    <dsp:input bean="GiftlistFormHandler.createGiftlistErrorURL"
               type="hidden" value="./lists.jsp"/>
    Name of event <span class=help>(i.e. Harry's Wedding List)</span><br>
    <dsp:input bean="GiftlistFormHandler.eventName" size="25"
               type="text" value="New Event"/>
    <p>
         <dsp:input bean="GiftlistFormHandler.createGiftlist"
              type="submit" value="Make new gift list"/>
    </dsp:form>
    </td>
   </tr>
  </table>
  </blockquote>
 </dsp:oparam>
 <dsp:oparam name="default">
  <blockquote>
  <b>Login or Register and create a gift list!</b><p>
  Registered customers at Pioneer Cycling are able to create giftlists and
  share them with their friends. Let everyone know what gear you want
  for your birthday.
  <p>
  > <dsp:a href="my_profile.jsp">Login or Register </dsp:a> now and start working
on your giftlist.
  </blockquote>
 </dsp:oparam>
</dsp:droplet>

When customers select the “Make New Gift list” button, they are directed to the “create gift list” page where they enter information about the upcoming event such as date, type, and description. This form again uses the GiftlistFormHandler to accept customer input and to call handlers to save the information in the repository. The following code sample (from lists_create.jsp) shows how input is taken and handle methods are called.

Note: The “. . .” markers in the following code sample indicate a place where code has been removed to clarify the sample.

<%--
This page allows a user to create a new giftlist
--%>

<dsp:importbean bean="/atg/commerce/gifts/GiftlistFormHandler"/>
<dsp:importbean bean="/atg/dynamo/droplet/ForEach"/>
<dsp:importbean bean="/atg/dynamo/droplet/Switch"/>
<dsp:importbean bean="/atg/dynamo/droplet/IsEmpty"/>
<dsp:importbean bean="/atg/userprofiling/Profile"/>

<span class=storebig>Create new giftlist</span>
<dsp:form action="lists.jsp" method="POST">
<dsp:input bean="GiftlistFormHandler.saveGiftlistSuccessURL"
           type="hidden" value="./lists.jsp"/>
<dsp:input bean="GiftlistFormHandler.saveGiftlistErrorURL"
           type="hidden" value="./lists_new.jsp"/>
. . .

  <b>Event Name</b><br>
  <dsp:input bean="GiftlistFormHandler.eventName" size="40" type="text"/>
  <p>
  <b>Event Date</b>
  <dsp:select bean="GiftlistFormHandler.month">
    <dsp:droplet name="ForEach">
      <dsp:param bean="GiftlistFormHandler.months" name="array"/>
      <dsp:oparam name="output">
        <dsp:getvalueof id="option564" param="index"
             idtype="java.lang.Integer">
          <dsp:option value="<%=option564.toString()%>"/>
      </dsp:getvalueof>
      <dsp:valueof param="element">UNDEFINED</dsp:valueof>
      </dsp:oparam>
    </dsp:droplet>
  </dsp:select>
  <dsp:select bean="GiftlistFormHandler.date">
  <dsp:droplet name="ForEach">
    <dsp:param bean="GiftlistFormHandler.dates" name="array"/>
    <dsp:oparam name="output">
      <dsp:getvalueof id="option583" param="element"
           idtype="java.lang.String">
        <dsp:option value="<%=option583%>"/>
      </dsp:getvalueof>
      <dsp:valueof param="element">UNDEFINED</dsp:valueof>
    </dsp:oparam>
  </dsp:droplet>
  </dsp:select>
  <dsp:select bean="GiftlistFormHandler.year">
  <dsp:droplet name="ForEach">
    <dsp:param bean="GiftlistFormHandler.years" name="array"/>
    <dsp:oparam name="output">
      <dsp:getvalueof id="option602" param="element"
           idtype="java.lang.String">
        <dsp:option value="<%=option602%>"/>
      </dsp:getvalueof>
      <dsp:valueof param="element">UNDEFINED</dsp:valueof>
    </dsp:oparam>
    </dsp:droplet>
    </dsp:select>
   <p>
   <b>Event Type</b>
   <dsp:select bean="GiftlistFormHandler.eventType">
   <dsp:droplet name="ForEach">
     <dsp:param bean="GiftlistFormHandler.eventTypes" name="array"/>
     <dsp:oparam name="output">
       <dsp:getvalueof id="option627" param="element"
            idtype="java.lang.String">
         <dsp:option value="<%=option627%>"/>
       </dsp:getvalueof>
       <dsp:valueof param="element">UNDEFINED</dsp:valueof>
     </dsp:oparam>
     </dsp:droplet>
     </dsp:select><br>

  <b>Comments</b><br>
  <dsp:setvalue bean="GiftlistFormHandler.comments" value=""/>
  <dsp:textarea bean="GiftlistFormHandler.comments" rows="4"
       cols="40"></dsp:textarea>
<%--  <dsp:textarea bean="GiftlistFormHandler.comments" maxlength="254"
       value="" rows="4" cols="40"></dsp:textarea></dsp:textarea> --%>
  <p>

  <b>Event Description</b><br>
  <dsp:setvalue bean="GiftlistFormHandler.description" value=""/>
<%--  <dsp:textarea bean="GiftlistFormHandler.description" maxlength="254"
                    value="" rows="4" cols="40"></dsp:textarea> --%>
  <dsp:textarea bean="GiftlistFormHandler.description" rows="4"
       cols="40"></dsp:textarea>
  <p>
  <b>Extra information or special instructions</b><br>
  <%-- <dsp:textarea bean="GiftlistFormHandler.instructions"
        maxlength="254" value="" rows="4" cols="40"></dsp:textarea> --%>
  <dsp:textarea bean="GiftlistFormHandler.instructions" rows="4"
       cols="40"></dsp:textarea>
  <p>
  <b>Where should people ship the gifts?</b><p>
  <blockquote>
  <dsp:input bean="GiftlistFormHandler.isNewAddress" type="radio"
       checked="<%=true%>" value="false"/>Choose one of your saved
       shipping destinations.<br>
    <dsp:select bean="GiftlistFormHandler.shippingAddressId">
    <dsp:droplet name="ForEach">
      <dsp:param bean="GiftlistFormHandler.addresses" name="array"/>
      <dsp:oparam name="output">
        <dsp:getvalueof id="option695" param="key"
             idtype="java.lang.String">
          <dsp:option value="<%=option695%>"/>
        </dsp:getvalueof>
        <dsp:valueof param="element">UNDEFINED</dsp:valueof>
      </dsp:oparam>
    </dsp:droplet>
    </dsp:select><br>
  <p>
  <dsp:input bean="GiftlistFormHandler.isNewAddress" type="radio"
       value="true"/>New address below
  <p>
  If you want this address stored in your address book, please give it a
  nickname:<br>
  <dsp:input bean="GiftlistFormHandler.newAddressName" size="40"/><br>
  Name <br><dsp:input bean="GiftlistFormHandler.newAddress.firstName"
            name="firstName" size="15"/>
  <dsp:input bean="GiftlistFormHandler.newAddress.middleName"
       name="middleName" size="5"/>
  <dsp:input bean="GiftlistFormHandler.newAddress.lastName"
       name="lastName" size="15"/><br>
  Street address <br>
  <dsp:input bean="GiftlistFormHandler.newAddress.address1"
       name="address1" size="40"/><br>
  <dsp:input bean="GiftlistFormHandler.newAddress.address2"
       name="address2" size="40"/><br>
  <table border=0 cellspacing=0 cellpadding=0>
    <tr valign=top>
      <td>City<br>
      <dsp:input bean="GiftlistFormHandler.newAddress.city" name="city"
           size="15"/></td>
      <td>State<br>
      <dsp:select bean="GiftlistFormHandler.newAddress.state">
           <%@ include file="StatePicker.jspf" %>
      </dsp:select></td>
     <td>Postal Code<br>
     <dsp:input bean="GiftlistFormHandler.newAddress.postalCode"
          name="postalCode" size="15"/></td>
    </tr>
  </table>

     Country
            <dsp:select bean="GiftlistFormHandler.newAddress.country">
              <%@ include file="CountryPicker.jspf" %>
            </dsp:select>
  </blockquote>

  <p>&nbsp;<br>
  </td>
  </tr>

  <tr valign=top>
  <td width=30%>
  <span class=help>
  Decide if you want your list to be public yet. When you make your list
  public, your friends can
  find your list by searching.
  </span>

  </td>
  <td></td>
  <td>
  <table width=100% cellpadding=0 cellspacing=0 border=0>
  <tr><td class=box-top-store>Gift list public?</td></tr></table>
  <p>

  <dsp:input bean="GiftlistFormHandler.isPublished" name="published"
       type="radio" value="true"/> Make my list public now<br>
  <dsp:input bean="GiftlistFormHandler.isPublished" name="published"
       type="radio" checked="<%=true%>" value="false"/> Don't make my list
       public yet

  <p>&nbsp;<br>

  <dsp:input bean="GiftlistFormHandler.saveGiftlist" type="submit"
       value="Save gift list"/>

Here is the screenshot for lists_new.jsp. It takes the input from customers and saves it to the repository.

Editing and Deleting Gift Lists

The implementations of editing and deleting are similar to creating gift lists. On the “My Lists” page, there is an edit this list link below each gift list. This link directs the customer to the edit gift list page and passes the gift list id through. For the Pioneer Cycling store, we did this in lists_edit.jsp. It calls GiftlistLookupDroplet to get the gift list item from the repository and checks the owner of the gift list against the profile id. If they match, then the gift list information is displayed in the same format as create and options to save and delete are provided. The following code sample demonstrates how to call GiftlistLookupDroplet and how to check for permissions.

Note: The “. . .” markers in the following code sample indicate a place where code has been removed to clarify the sample.

lists_edit.jsp:

<dsp:droplet name="/atg/commerce/gifts/GiftlistLookupDroplet">
  <dsp:param name="id" param="giftlistId"/>
  <dsp:oparam name="output">
    <dsp:droplet name="IsEmpty">
      <dsp:param name="value" param="element"/>
      <dsp:oparam name="false">
        <dsp:setvalue paramvalue="element" param="giftlist"/>

        <dsp:droplet name="/atg/dynamo/droplet/Switch">
        <dsp:param bean="Profile.id" name="value"/>
        <dsp:getvalueof id="nameval3" param="giftlist.owner.id"
             idtype="java.lang.String">
<dsp:oparam name="<%=nameval3%>">
        <dsp:form action="lists.jsp" method="POST">

. . .

          <b>Event Name</b><br>
          <dsp:input bean="GiftlistFormHandler.eventName"
               paramvalue="giftlist.eventName" size="40" type="text"/>

. . .
            <p>&nbsp;<br>
            <dsp:input
                 bean="GiftlistFormHandler.deleteGiftlistSuccessURL"
                 type="hidden" value="./lists.jsp"/>
            <dsp:input bean="GiftlistFormHandler.deleteGiftlistErrorURL"
                 type="hidden" value="<%=thisPage.getNewUrl()%>"/>
            <dsp:input bean="GiftlistFormHandler.deleteGiftlist"
                 name="delete" type="submit" value="Delete gift list"/>
            <dsp:input
                 bean="GiftlistFormHandler.updateGiftlistSuccessURL"
                 type="hidden" value="./lists.jsp"/>
            <dsp:input bean="GiftlistFormHandler.updateGiftlistErrorURL"
                 type="hidden" value="<%=thisPage.getNewUrl()%>"/>
            <dsp:input bean="GiftlistFormHandler.updateGiftlist"
                 name="update" type="submit" value="Save gift list"/>
       </core:createUrl>
          </td>
          </tr>
          </table>
          </dsp:form>
          </dsp:oparam>
          <dsp:oparam name="default">
          You do not have permission to access the specified giftlist
          </dsp:oparam>
          </dsp:droplet>
      </dsp:oparam>
      <dsp:oparam name="true">
        <font color=cc0000><STRONG><UL>
        Either no giftlist found or you do not have permission to access
        it.
      </dsp:oparam>
    </dsp:droplet>
  </dsp:oparam>
</dsp:droplet>
 
loading table of contents...