Class Name

atg.repository.servlet.NavHistoryCollector

Component(s)

/atg/commerce/catalog/CatalogNavHistoryCollector

The CatalogNavHistoryCollector servlet bean can be used to create a “breadcrumb trail.” That is, it constructs a list of the items the customer has visited to arrive at the current page and then creates and displays links to the items. This trail enables the customer to easily go back to previously visited items.

The CatalogNavHistoryCollector servlet bean manages the customer’s navigation path by adding or removing the repository items that the customer has viewed from CatalogNavHistory.navHistory, the property that stores the stack of repository items.

Input Parameters

item (either this or itemName must be used)
The repository item that is currently being viewed. This is the item that will be added to CatalogNavHistory.navHistory.

itemName (either this or item must be used)
The name of the current page. When this page is displayed as a breadcrumb, this name will be used as the anchor text in the link back to the page.

navAction
The operation to be performed on the navHistory stack. Choices are push, pop, and jump. An unset navAction will be treated as push.

navCount (Required)
Used to detect the use of the Back button in order to reset the navigation path. To use this feature, at the top of each page set a page parameter named navCount to the value of the CatalogNavHistory.navCount property. For example:

<param name="navCount" value="bean:CatalogNavHistory.navCount">

Then, when you call the CatalogNavHistoryCollector servlet bean, set the value of the navCount input parameter to the current value of the CatalogNavHistory.navCount property. CatalogNavHistoryCollector compares this value to the value of the navCount page parameter. If the values are not equal, then the Back button was used to get to the page.

Output Parameters

None.

Open Parameters

output
None.

Example

This example demonstrates how to collect the navigation history using CatalogNavHistoryCollector. This JSP fragment should be invoked in each page that adds an item to the navHistory stack.

<dsp:droplet name="/atg/commerce/catalog/CategoryLookup">
<dsp:param param="itemId" name="id"/>

<dsp:oparam name="output">

   <dsp:droplet name="/atg/commerce/catalog/CatalogNavHistoryCollector">
   <dsp:param param="element" name="item"/>
   <dsp:param value="push" name="navAction"/>
   <dsp:param bean="/atg/commerce/catalog/CatalogNavHistory.navCount"
              name="navCount"/>
   </dsp:droplet>

</dsp:oparam>
</dsp:droplet>

This second example demonstrates how to render a list of the locations the customer has visited. These locations are displayed as a path, such as Fruit > Citrus Fruit > Oranges. Each category or product name in the path is a link back to the corresponding item. Clicking one of these links causes the items below it in the hierarchy to pop off the stack.

<dsp:droplet name="/atg/dynamo/droplet/ForEach">
 <dsp:param bean="CatalogNavHistory.navHistory" name="array"/>
 <dsp:oparam name="output">
    <dsp:getvalueof id="a6" param="element.template.url"
                idtype="java.lang.String">
<dsp:a href="<%=a6%>">
    <dsp:param param="element.repositoryId" name="itemId"/>
    <dsp:param value="pop" name="navAction"/>
    <dsp:param bean="CatalogNavHistory.navCount" name="navCount"/>
    <dsp:valueof param="element.displayName"/>
    </dsp:a></dsp:getvalueof>
 </dsp:oparam>
</dsp:droplet>
 
loading table of contents...