Several servlet beans are provided to support gift list and wish list functionality. These servlet beans can be used with forms to look up gift lists and gift items, as well as to perform actions, such as removing or purchasing items from a gift list, adding gift lists to a profile, and removing gift lists from a profile.
Lookup Servlet Beans
The GiftlistLookupDroplet
and GiftitemLookupDroplet
servlet beans, located in Nucleus at /atg/commerce/gifts/
, are instances of class atg.repository.servlet.ItemLookupDroplet
. These servlet beans provide a way to search for and display gift lists and gift items in the Giftlists
repository based on ID. For information about the input, output, and open parameters of servlet beans instantiated from ItemLookupDroplet
, refer to Appendix B: ATG Servlet Beans in the ATG Page Developer's Guide.
The following code example demonstrates how to use the GiftlistLookupDroplet
to look up a gift list in the repository and check that the owner ID equals the ID of the current profile before displaying the gift list.
<dsp:droplet name="/atg/commerce/gifts/GiftlistLookupDroplet"> <dsp:param param="giftlistId" name="id"/> <dsp:oparam name="output"> <dsp:droplet name="IsEmpty"> <dsp:param param="element" name="value"/> <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 var="ownerId" param="giftlist.owner.id"/> <dsp:oparam name="${ownerId}"> <%-- display gift list info here --%> </dsp:oparam> </dsp:droplet> </dsp:oparam> </dsp:droplet> </dsp:oparam> </dsp:droplet>
Note: In multisite environments, the GiftlistLookupDroplet
should be used in conjunction with the GiftlistSiteFilterDroplet
to ensure that only gift lists that are appropriate for the site context are displayed. For more details, see Filtering Multisite Gift and Wish Lists in the ATG Commerce Guide to Setting Up a Store.
GiftlistDroplet
The GiftlistDroplet
servlet bean (class atg.commerce.gifts.GiftlistDroplet
), which is located in Nucleus at /atg/commerce/gifts/
, adds or removes customer A’s gift list from customer B’s otherGiftlists
Profile property, depending on the action supplied via the action
input parameter. This enables the given customer to easily find those for whom the customer has shopped or is shopping.
GiftlistDroplet
takes the following input parameters:
action
: The action to perform on the gift list (“add” or “remove”). (Required)giftlistId
: The ID of the gift list. (Required)profile
: The profile of the current customer. If not passed, the profile will be resolved by Nucleus.
GiftlistDroplet
does not set any output parameters. It renders the following open parameters (oparams
):
output
: Theoparam
rendered if the gift list is added or removed successfully from a profile.error
: Theoparam
rendered if an error occurs while adding or removing the gift list.
The following code example demonstrates how to use the GiftlistDroplet
to add a gift list that was retrieved in a search to a customer’s profile.
<dsp:droplet name="/atg/dynamo/droplet/IsEmpty"> <dsp:param param="giftlistId" name="value"/> <dsp:oparam name="false"> <dsp:droplet name="/atg/commerce/gifts/GiftlistDroplet"> <dsp:param param="giftlistId" name="giftlistId"/> <dsp:param value="add" name="action"/> <dsp:param bean="/atg/userprofiling/Profile" name="profile"/> <dsp:oparam name="output">Output</dsp:oparam> <dsp:oparam name="error">Error</dsp:oparam> </dsp:droplet> </dsp:oparam> </dsp:droplet>
GiftitemDroplet
Servlet beans instantiated from class atg.commerce.gifts.GiftitemDroplet
enable customers either to buy or to remove items from their own personal gift lists, depending on the configuration of the servlet bean. (For information on how to add items to a personal gift list, see GiftlistFormHandler. For information on how to buy items from another’s gift list, see CartModifierFormHandler.)
Two Oracle ATG Web Commerce servlet beans have been instantiated from GiftitemDroplet
; they are BuyItemFromGiftlist
and RemoveItemFromGiftlist
. They take the following input parameters, both of which are required:
giftId
: The ID of the gift.giftlistId
: The ID of the gift list.
They do not set any output parameters. They render the following open parameters:
output
: Theoparam
rendered if the item is bought or removed successfully from list.error
: Theoparam
rendered if an error occurs during processing.
The following code example demonstrates how to use the RemoveItemFromGiftlist
component to remove an item from a customer’s personal gift list.
<dsp:droplet name="/atg/dynamo/droplet/IsEmpty"> <dsp:param param="giftId" name="value"/> <dsp:oparam name="false"> <dsp:droplet name="/atg/commerce/gifts/RemoveItemFromGiftlist"> <dsp:param param="giftlistId" name="giftlistId"/> <dsp:param param="giftId" name="giftId"/> </dsp:droplet> </dsp:oparam> </dsp:droplet>