This section describes how Commerce Reference Store detects when a product is being viewed and then adds that product to the recently viewed list.

Detecting When a Product is Being Viewed

Depending on the type of product being displayed, the product detail page may be one of three JSPs found in store.war/browse/productDetailDisplay.jsp, productDetailMultiSkuContainer.jsp, or productDetailSingleSkuContainer.jsp. All three pages include the store.war/browse/gadgets/productLookupForDisplay.jsp gadget, which calls the /atg/commerce/catalog/ProductBrowsed component. This component dispatches a message each time a customer browses a product on the product detail page. To receive these messages, Commerce Reference Store includes a MessageSink component called the /atg/userprofiling/recentlyviewed/RecentlyViewedHistoryCollector.

When RecentlyViewedHistoryCollector receives a message, it determines if the message’s type is ViewItem and if the message’s item type is product. If both tests are true, RecentlyViewedHistoryCollector calls the RecentlyViewedTools component to add the product to the customer’s recently viewed list. RecentlyViewedHistoryCollector is a globally scoped component of class and it has the properties shown in the table below:




A string that represents the JMS message type that RecentlyViewedHistoryCollector should process. This property should be set to atg.dps.ViewItem.


A string that represents the item type that RecentlyViewedHistoryCollect should process. This property should be set to product.


A reference to the productCatalog repository. Commerce Reference Store sets this property to /atg/commerce/catalog/ProductCatalog.


A reference to the RecentlyViewedTools component. Commerce Reference Store sets this property to /atg/store/profile/recentlyviewed/RecentlyViewedTools.

In order to specify RecentlyViewedHistoryCollector as a message sink, Commerce Reference Store adds the necessary configuration to the /atg/dynamo/messaging/dynamoMessagingSystem.xml file.

Note: See the ATG Platform Programming Guide for more information on message sinks and the Patch Bay messaging system.

Adding a Product to the Recently Viewed List

The /atg/userprofiling/recentlyviewed/RecentlyViewedTools component performs all the calls required to read and write information to and from the recently viewed list stored in the Profile repository. This component also includes some convenience methods for tasks such as determining if a product has expired and determining if the recently viewed list contains duplicates. The RecentlyViewedTools component is a globally-scoped component of class and it has the properties shown in the table below:




A reference to the utility component /atg/userprofiling/ProfileTools, used for working with user profiles. RecentlyViewedTools uses this component to retrieve user profiles.


An int that specifies the maximum number of products that should persist in the recentlyViewedProducts profile property. Default is -1, which means no limit.


An int that specifies the amount of time a product should remain in the recentlyViewedProducts list, defined in hours. The default for this property is 0, which indicates that there is no expiry period.


This property determines the behavior of recently viewed lists in a multisite environment. There are three potential values: all, current, and shareable type ID. This setting affects how products are added to the recently viewed list and also how they are filtered for display in the Recently Viewed Products panel. For detailed information on the effect of siteScope when adding products to the recently viewed list, continue reading this section. For detailed information on the effect of siteScope when filtering recently viewed products, see Filtering Products in the Recently Viewed List.


The path to the CurrentDate component, which RecentlyViewedTools uses to retrieve current system times for timestamps.

In preparation for adding a product to the recently viewed list, RecentlyViewedTools retrieves the current recently viewed list from the customer’s profile and scrubs it of any products that are out of date or no longer exist. It also creates a new recentlyViewedProduct item with the current site’s ID and the current timestamp. This is the item that will potentially be added to the recently viewed list.

Next, RecentlyViewedTools builds a “virtual” list of recentlyViewedProduct items that contains only those items in the customer’s recently viewed list that are appropriate for the current site context. The items that are included are determined by the RecentlyViewedTools.siteScope property. The size of the list is determined by the RecentlyViewedTools.recentlyViewedSize property. The process for building virtual lists is described below:

After building the virtual list for the current site context, RecentlyViewedTools determines if the new recentlyViewedProduct has a site ID that matches one of the IDs associated with the virtual list. If so, RecentlyViewedTools adds the recentlyViewedProduct to the list, assuming the list limit has not been reached yet. If the virtual list is full, RecentlyViewedTools removes one or more of the oldest recentlyViewedProduct items to make room for the new item before adding it to the beginning of the list.

Note: RecentlyViewedTools would only need to remove more than one item from a recently viewed list to make room for a new item if the recentlyViewedSize value had been changed to a lower value, for example, prior to a server restart.

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