Class ItemLookupDroplet

  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.nucleus.servlet.ServletService
                  extended by atg.nucleus.servlet.HttpServletService
                      extended by atg.servlet.DynamoServlet
                          extended by atg.repository.servlet.ItemLookupDroplet
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, ParameterServlet, java.util.EventListener, javax.servlet.Servlet
Direct Known Subclasses:

public class ItemLookupDroplet
extends DynamoServlet

This servlet looks for a RepositoryItem by its id from within a Repository. If the item is found, output is rendered. If the item is not found empty is rendered. The repository and item descriptor type can be configured through properties. If the useParams property is true, then the repository and item descriptor can be resolved through input parameters. One can configure this droplet to define a mapping from a key to an alternate set of repositories.
For example:

The invocation of the droplet can then be invoked with the following parameters:
  <dsp:droplet name="/atg/commerce/catalog/ProductLookup">
    <dsp:param name="id" param="productId"/>
    <dsp:param  name="repositoryKey" bean="/OriginatingRequest.requestLocale.localeString"/>
    <dsp:setvalue param="product" paramvalue="element"/>
    <dsp:oparam name="output">
       <dsp:getvalueof id="a11" param="product.template.url" idtype="java.lang.String">
         <dsp:a href="<%=a11%>">
            <dsp:param name="prod_id" param="product.repositoryId"/>
            <dsp:valueof param="product.displayName"/>
If the mapping for the provided key is found that repository will be used, otherwise the system will fall back to the default repository and search for the item.

If the item cannot be found in the repository searched (e.g. the french product catalog), then the droplet will once again fall back to the default repository and attempt to find the item using the same id. Obviously this is only useful if the items have the exact same id in each repository.

In this example if you are french and attempt to look at product 1234, and product 1234 is defined in the french product catalog you will see that item. However if 1234 is not defined then you will see the default english version of 1234.

This behavior can be modified with use of the useDefaultRepository and getDefaultItem properties. If useDefaultRepository is false and an alternate repository cannot be found, then no repository is searched and empty is serviced. Like wise, if an alternative repository is selected, but the item cannot be found, and if getDefaultItem is false, then the default repository will not be searched and empty will be serviced.

The required input paramters for this servlet are:

The id of the item to lookup
The following parameters are optional:
If specified this parameter will be used as a key to map to a secondary set of repositories.
This parameter can be used to change the default name of the element which is bound into the scope of the output oparam.
The repository within which to look for the item. It is recommended to not use this parameter and to define different instances of the ItemLookupDroplet for each set of repositories you wish to use.
The name of the Item Descriptor to use to load the item. It is recommended to not use this parameter and to setup the item descriptor through property configuration.

The following parameters are rendered:

Rendered if the item was found in the repository
Rendered in all other cases, e.g. item not found, user did not specify a required parameter.

The output parameters for this servlet are:

Set to the RepositoryItem corresponding to the id supplied
Any exception that may have occured while looking up the item

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
Fields inherited from class atg.servlet.DynamoServlet
mAllowCleanupRequest, mParameters
Fields inherited from class atg.nucleus.servlet.ServletService
Fields inherited from class atg.nucleus.GenericService
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
Constructor Summary
Method Summary
protected  void commitTransaction(javax.transaction.Transaction pTransaction)
          Commits the supplied transaction
protected  javax.transaction.Transaction ensureTransaction()
          This method ensures that a transaction exists before returning.
 ServiceMap getAlternateRepositories()
          Returns property AlternateRepositories
 java.lang.String getItemDescriptor()
          Returns property ItemDescriptor
 Repository getRepository()
          Returns property Repository
 javax.transaction.TransactionManager getTransactionManager()
          Returns property TransactionManager.
 boolean isEnsureTransaction()
          Returns property EnsureTransaction
 boolean isGetDefaultItem()
          Returns property GetDefaultItem
 boolean isUseDefaultRepository()
          Returns property UseDefaultRepository
 boolean isUseParams()
          Returns property UseParams
 void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Look for the RepositoryItem and if found render the output oparam by binding the item as a parameter.
 void setAlternateRepositories(ServiceMap pAlternateRepositories)
          Sets property AlternateRepositories
 void setEnsureTransaction(boolean pEnsureTransaction)
          Sets property EnsureTransaction
 void setGetDefaultItem(boolean pGetDefaultItem)
          Sets property GetDefaultItem
 void setItemDescriptor(java.lang.String pItemDescriptor)
          Sets property ItemDescriptor
 void setRepository(Repository pRepository)
          Sets property Repository
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Sets property TransactionManager
 void setUseDefaultRepository(boolean pUseDefaultRepository)
          Sets property UseDefaultRepository
 void setUseParams(boolean pUseParams)
          Sets property UseParams
Methods inherited from class atg.servlet.DynamoServlet
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, service, service, setParameter
Methods inherited from class atg.nucleus.servlet.ServletService
destroy, getServletConfig, getServletInfo, init, setServletInfo
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
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, toString, wait, wait, wait

Field Detail


public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail


public ItemLookupDroplet()
Method Detail


public void setRepository(Repository pRepository)
Sets property Repository


public Repository getRepository()
Returns property Repository


public void setItemDescriptor(java.lang.String pItemDescriptor)
Sets property ItemDescriptor


public java.lang.String getItemDescriptor()
Returns property ItemDescriptor


public void setAlternateRepositories(ServiceMap pAlternateRepositories)
Sets property AlternateRepositories


public ServiceMap getAlternateRepositories()
Returns property AlternateRepositories


public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Sets property TransactionManager


public javax.transaction.TransactionManager getTransactionManager()
Returns property TransactionManager. If the internal transaction manager reference is null, it will be retrieved from the Repository if possible


public void setEnsureTransaction(boolean pEnsureTransaction)
Sets property EnsureTransaction


public boolean isEnsureTransaction()
Returns property EnsureTransaction


public void setUseParams(boolean pUseParams)
Sets property UseParams


public boolean isUseParams()
Returns property UseParams


public void setUseDefaultRepository(boolean pUseDefaultRepository)
Sets property UseDefaultRepository


public boolean isUseDefaultRepository()
Returns property UseDefaultRepository


public void setGetDefaultItem(boolean pGetDefaultItem)
Sets property GetDefaultItem


public boolean isGetDefaultItem()
Returns property GetDefaultItem


protected javax.transaction.Transaction ensureTransaction()
This method ensures that a transaction exists before returning. If there is no transaction, a new one is started and returned. In this case, you must call commitTransaction when the transaction completes.


protected void commitTransaction(javax.transaction.Transaction pTransaction)
Commits the supplied transaction


public void service(DynamoHttpServletRequest pRequest,
                    DynamoHttpServletResponse pResponse)
             throws javax.servlet.ServletException,
Look for the RepositoryItem and if found render the output oparam by binding the item as a parameter. If no item can be found render the empty oparam.

service in class DynamoServlet
pRequest - the request to be processed
pResponse - the response object for this request
javax.servlet.ServletException - an application specific error occurred processing this request - an error occurred reading data from the request or writing data to the response.