Class Name |
|
|---|---|
Components |
|
The CollectionFilter servlet beans use collection filtering components to reduce objects in a collection. Each servlet bean works with a different collection filtering component.
InventoryFilterDropletfor a collection of products, determines which SKUs are available, as determined by the Inventory Manager at the time of execution. This servlet bean accessesInventoryFilter, which handles the filtering action.ProductFilterDropletexecutes bothInventoryFilterDropletandStartEndDateFilterDropletto return only those items that satisfy both sets of requirements. For example, a product that’s in stock and has an activestartDatewill be returned while one with the samestartDatebut is out of stock won’t be returned. This servlet bean accessesProductFilter, which handles the filtering action.ExcludeItemInCartFilterDropletreturns those products that are not in the user’s shopping cart. This servlet bean relies onExcludeItemsInCartFilterto determine the items in the shopping cart and to eliminate them from the collection.CartSharingFilterDropletuses theCartSharingFilterto return only products from sites that are within the cart sharing group.GiftlistSiteFilterDropletfilters a specified collection of gift lists or gift items.
The primary discussion of this class resides in Appendix B: ATG Servlet Beans of the Page Developer's Guide. For details about collection filtering components and caching, see the Filtering Collections chapter in the Personalization Programming Guide.
Note that each droplet’s filter input parameter has a different default value of class CollectionFilter:
InventoryFilterDropletuses/atg/registry/CollectionFilters/InventoryFilterExcludeItemInCartFilterDropletuses/atg/registry/CollectionFilters/ExcludeItemInCartFilterProductFilterDropletuses/atg/registry/CollectionFilters/ProductFilterCartSharingFilterDropletuses/atg/registry/COllectionFilters/CartSharingFilter
ProductFilterDroplet Example
In this example, ProductFilterDroplet causes the filters (InventoryFilter and StartEndDateFiler)specified in the ProductFilter to apply their filtering mechanisms to a collection of products. The resultant collection of products that are in stock and active are displayed.
<dspel:droplet name="/atg/commerce/catalog/CategoryLookup">
<dspel:param name="Id" param="catId"/>
<dspel:oparam name="output">
<%
String collIdentifierKey = request.getParameter("catId") + "-childprd";
%>
<dspel:droplet name="/atg/commerce/collections/filter/droplet/
ProductFilterDroplet">
<dsp:param name="collection" param="item.childproducts/>
<dsp:param name="collectionIdentifierKey" value="<%=collIdentifierKey
%>"/>
<dspel:oparam name="output">
Featured Plants:
<p><dsp:droplet name="/atg/dynamo/droplet/ForEach">
<dsp:param name="array" param="filteredCollection"/>
<dsp:oparam name="output">
<dspel:valueof param="element"/>
</dspel:oparam>
</dsp:droplet>
</dspel:oparam>
<dspel:oparam name="empty">
There are currently no outdoor plants
</dspel:oparam>
</dspel:droplet>
</dspel:oparam>
</dspel:droplet>GiftListSiteFilterDroplet Examples
This JSP excerpt shows one example of how you can use GiftlistSiteFilterDroplet to filter gift lists. No site scope is passed in, so the GiftlistSiteFilter uses the GiftlistManager component’s siteScope, which for the purposes of this example is set to the atg.ShoppingCart shareable type component. Also, no site IDs are provided, so the filtered gift lists will come from the current site and sites that share a shopping cart with the current site only.
<dsp:droplet
name="/atg/commerce/collections/filter/droplet/GiftlistSiteFilterDroplet">
<&-- Specify the collection to filter --%>
<dsp:param name="collection" bean="Profile.giftlists"/>
<dsp:oparam name="output">
<%-- Iterate through the collection. --%>
<dsp:droplet name="="/atg/dynamo/droplet/ForEach">
<dsp:param name="array" param="filteredCollection"/>
<dsp:oparam name="output">
<dsp:setvalue param="giftList" paramvalue="element"/>
<dsp:getvalueof var="eventName" param="giftList.eventName"/>
<c:out value="${eventName}"/>
</dsp:oparam>
</dsp:droplet>
</dsp:oparam>
</dsp:droplet>This JSP excerpt filters a collection of wish list items. A site scope value of current is passed to the filter but no site IDs are passed, resulting in a collection of items from the current site only.
<dsp:droplet
name="/atg/commerce/collections/filter/droplet/GiftlistSiteFilterDroplet">
<&-- Specify the collection to filter and the site scope. --%>
<dsp:param name="collection" bean="Profile.wishlist.giftlistItems"/>
<dsp:param name="siteScope" value="current"/>
<dsp:oparam name="output">
<%-- Iterate through the collection. --%>
<dsp:droplet name="="/atg/dynamo/droplet/ForEach">
<dsp:param name="array" param="filteredCollection"/>
<dsp:oparam name="output">
<dsp:setvalue param="giftItem" paramvalue="element"/>
<dsp:getvalueof var="displayName" param="giftItem.displayName"/>
<c:out value="${displayName}"/>
</dsp:oparam>
</dsp:droplet>
</dsp:oparam>
</dsp:droplet>Notes:
The
GiftlistSiteFilterandGiftlistSiteFilterDropletcomponents can be configured to use caching to improve filtering performance, just as you would for any filter based on theCollectionFilterclass. See Caching Filtered Content in the Personalization Programming Guide.To pass site IDs to the
GiftlistFilterDroplet, use a comma-separated list.

