The store.war/cart/gadgets/giftSelection.jsp page renders the gift selection options for each gift item. This page use the atg.commerce.promotion.GiftWithPurchaseSelectionChoicesDroplet to obtain a list of GiftWithPurchaseSelectionChoice beans associated with the current gift. Each GiftWithPurchaseSelectionChoice bean contains a product, and its associated SKUs, that is available for selection for the current gift.

Depending on how a gift is configured in the Business Control Center, it may have a giftType that consists of a single product or multiple products. The sku and product gift types include a single product, hence one GiftWithPurchaseSelectionChoice bean is returned for this gift type. The category, skuContentGroup, and productContentGroup gift types include multiple products, so multiple GiftWithPurchaseSelectionChoice beans are returned.

The list of GiftWithPurchaseSelectionChoice beans is passed to the /atg/commerce/collections/filter/droplet/InventoryFilterDroplet. This droplet iterates over each bean, using the Commerce Reference Store-specific filter /atg/registry/CollectionFilters/GWPSelectionInventoryFilter, and checks if the SKUs are available in inventory. Any GiftWithPurchaseSelectionChoice bean that has no SKUs available in inventory is filtered out.

The gift selection page iterates over the filtered GiftWithPurchaseSelectionChoice beans and renders a row for each bean that displays the product and SKU choices for that bean. The giftSelection.jsp gadget renders a JavaScript-based picker similar to what is used on the product detail pages.

Error Messages on the Gift Selection Page

The handling of error messages on the gift selection page is done through AJAX. An AJAX request is sent to the server when the customer chooses a gift in the popup page. If an error occurs during the request processing, JavaScript retrieves the error messages from a JSON response and injects them into the HTML structure of the popup. To implement this solution, the store.war/cart/gadgets/giftSelection.jsp gadget specifies the store.war/cart/json/giftErrors.jsp JSP page as the error URL to use when the gift selection has been made via an AJAX request:

<dsp:input bean="GiftWithPurchaseFormHandler.ajaxMakeGiftSelectionErrorURL"
           type="hidden" value="${contextroot}/cart/json/giftErrors.jsp"/>

The giftErrors.jsp page extracts the errors from the /atg/commerce/promotion/GiftWithPurchaseFormHandler.formExceptions property using the /atg/dynamo/droplet/ErrorMessageForEach droplet and then creates a JSON object that contains an array of the errors that occurred during request processing. The handleJSON() JavaScript function from store.war/javascript/picker.js processes the received JSON object and checks whether it contains any errors. If so, the errors are injected into a special reserved <div> container inside the gift selection popup. Using this method to render error messages improves the performance of the gift popup page because only a portion of the page is re-rendered when errors occur, not the entire page.


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