atg.repository.servlet
Class NavHistory

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.logging.ApplicationLoggingImpl
          extended by atg.repository.servlet.NavHistory
All Implemented Interfaces:
ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging
Direct Known Subclasses:
CatalogNavHistory

public class NavHistory
extends ApplicationLoggingImpl

When you are walking in the woods, experts recommend carrying a loaf of bread and throwing down bread crumbs everywhere you walk so that when you would like to return, you can follow a trail of breadcrumbs to your home.

In this implementation of bread crumbs we will keep track of the path that the user has traversed from the top of the site to the current location. We will keep a stack of locations visited and move items on and off that stack as needed to keep the list a concise path from user's current position to the "top" of the site.

This class is intended to be instantiated as a session scoped component and used with the NavHistoryCollector.

There are 4 ways that a user can move:

  1. When the user navigates in the forward direction or down the hierarchy, we push another item on the stack.
  2. When he navigates up the hierarchy by clicking on breadcrumb or another navigational item, we will pop the appropriate number of items off the stack.
  3. If the user hits the back button one or more times and then resumes navigation we are able to recognize that and reset the navigation path, so that we will add breadcrumbs from the position at which navigation was resumed rather than the farthest point the user reached.
  4. Finally, if the user jumps to an unrelated area of the site, as if by a global navigation or some other link, we can jump to that area. If there is a default navigation path to the page jumped to, as in a hierarchical structure, that will be filled in. However, to have anything filled in you must extend this class and implement the getDefaultHistory() method as appropriate to your repository structure.

    This works for navigation among items in a single repository or multiple repositories. If you have a site with a catalog and a magazine, for example, and each has a separate repository, then you can use a single NavHistory for the whole site or you may maintain a MagazineNavHistory and a CatalogNavHistory service so that you can remember position in the Magazine while the user visits the catalog and vice versa.

    Usage:

    The property NavHistory.navHistory is a LinkedList of objects which may be RepositoryItem or NavHistoryItems which represent the special pages like "search" and "home". To render the navigation history, which gives upwards navigation:

     <droplet bean="/atg/dynamo/droplet/ForEach">
       <param name="array" value="property:NavHistory.navHistory">
       <oparam name="output">
          <a href="param:element.template.url">
          <param name="itemType" value="param:element.itemDescriptor.itemDescriptorName">
          <param name="itemId" value="param:element.repositoryId">
          <param name="navAction" value="pop">
          <valueof param="element.displayName"></valueof>
          </a>
       </oparam>
     </droplet>
    


    Field Summary
    static java.lang.String CLASS_VERSION
              Class version string
     
    Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
    DEFAULT_LOG_TRACE_STATUS
     
    Fields inherited from interface atg.nucleus.logging.ApplicationLogging
    DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
     
    Constructor Summary
    NavHistory()
               
     
    Method Summary
     java.util.LinkedList getDefaultHistory(java.lang.Object pItem)
              Use this method to return the navhistory to display if there is no actual history in the user's session.
     int getNavCount()
               
     java.util.LinkedList getNavHistory()
               
     void incrementNavCount()
               
     boolean navigate(java.lang.Object pItem, java.lang.String pNavAction)
              This method uses navAction to decide how to place pItem on the NavHistory property and then does it.
     void resetHistory()
              this method erases all navHistory
     void setNavCount(int pNavCount)
               
     void setNavHistory(java.util.LinkedList pNavHistory)
               
     java.lang.String toString()
              For debugging purposes, this method can be used to print the contents of the navHistory property.
     
    Methods inherited from class atg.nucleus.logging.ApplicationLoggingImpl
    addGlobalLogListeners, addLogListener, getLoggingForVlogging, getLoggingIdentifer, getLoggingIdentifier, getLogListenerCount, getLogListeners, initializeFromServiceEvent, isAutoInitListeners, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, removeLogListener, sendLogEvent, setAutoInitListeners, setLoggingDebug, setLoggingError, setLoggingIdentifier, setLoggingInfo, setLoggingTrace, setLoggingWarning
     
    Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
    vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Field Detail

    CLASS_VERSION

    public static java.lang.String CLASS_VERSION
    Class version string

    Constructor Detail

    NavHistory

    public NavHistory()
    Method Detail

    setNavHistory

    public void setNavHistory(java.util.LinkedList pNavHistory)

    getNavHistory

    public java.util.LinkedList getNavHistory()

    setNavCount

    public void setNavCount(int pNavCount)

    getNavCount

    public int getNavCount()

    incrementNavCount

    public void incrementNavCount()

    resetHistory

    public void resetHistory()
    this method erases all navHistory


    navigate

    public boolean navigate(java.lang.Object pItem,
                            java.lang.String pNavAction)
    This method uses navAction to decide how to place pItem on the NavHistory property and then does it.


    getDefaultHistory

    public java.util.LinkedList getDefaultHistory(java.lang.Object pItem)
    Use this method to return the navhistory to display if there is no actual history in the user's session. For example, if there is a hierarchical structure to your repository, if a user jumps to some item, you can display that item's parent category, and the 'grandparent' up to the top of the hierarchy. In this base class, we return an empty linked list, but the developer is encouraged to override this method to fit the structure of the repository being navigated.


    toString

    public java.lang.String toString()
    For debugging purposes, this method can be used to print the contents of the navHistory property.

    Overrides:
    toString in class java.lang.Object