Looks up an item in one or more repositories based on the item’s ID and, optionally, site context, then renders the item on the page.
Class Name |
|
---|---|
Component |
|
Required Input Parameters
id
The ID of the item to look up.
repositoryKey
A key that maps to a secondary set of repositories.
Optional Input Parameters
repository
The repository to search.
Note: Use of this parameter is not recommended. Instead, you should define different instances of the ItemLookupDroplet
for each set of repositories.
itemDescriptor
The name of the item descriptor to use to load the item.
Note: Use of this parameter is not recommended. Instead, you should specify the item descriptor in the itemDescriptor
property of the servlet bean.
sites
The sites to use when determining if the retrieved item is appropriate for the site context and should therefore be rendered. If this parameter is omitted, the current site is used. If, however, you want to search in a site other than the current site, or there is no current session (for example, within the context of an email template), then you may want to explicitly provide the sites to use for comparison. If you provide more than one site, the item must be a member of at least one of the sites in order for it to be rendered. The sites
parameter must be a Collection
of Site
objects. See Usage Notes below for more details on site filtering.
Output Parameters
element
Set to the RepositoryItem
corresponding to the ID supplied.
error
Any exception that might occur while looking up the item.
Open Parameters
The following list describes the output and open parameters of the ItemLookupDroplet
.
output
Rendered if the item is found in the repository.
empty
Rendered in all other cases, such as item not found, site visitor did not specify a required parameter.
wrongSite
Rendered if the item is found in the repository but does not belong in the specified site context. This makes the item accessible if you need it. See Usage Notes below for more details on site filtering.
Usage Notes
ItemLookupDroplet
displays items in a repository. If your site uses more than one repository, you can create multiple instances of this servlet bean and configure each one differently. The repository and item descriptor type can be set through properties. If the useParams
property is true, then the repository and item descriptor are resolved through input parameters. You can configure this servlet bean to define a mapping from a key to an alternate set of repositories.
For example, an ItemLookupDroplet
servlet bean named ProductLookup
might have the following properties:
$class=atg.repository.servlet.ItemLookupDroplet repository=/atg/commerce/catalog/ProductCatalog itemDescriptor=product alternateRepositories=\ fr_FR=/atg/commerce/catalog/FrenchProductCatalog ja_JP=/atg/commerce/catalog/JapaneseProductCatalog de_DE=/atg/commerce/catalog/GermanProductCatalog
The servlet bean can then be invoked with the following parameters:
<dsp:droplet name="/atg/commerce/catalog/ProductLookup"> <dsp:param name="id" param="productId"/> <dsp:param bean="/OriginatingRequest.requestLocale.localeString" name="repositoryKey"/> <dsp:setvalue param="product" paramvalue="element" <dsp:oparam name="output"> <dsp:getvalueof var="a11" param="product.template.url" vartype="java.lang.String"> <dsp:a href="${a11}"> <dsp:param name="prod_id" param="product.repositoryId"/> <dsp:valueof param="product.displayName"/> </dsp:a> </dsp:getvalueof> </dsp:oparam> </dsp:droplet>
If the mapping for the provided key is found, that repository is used. Otherwise, the system falls back to the default repository and searches for the item.
If the item cannot be found in the repository searched (such as the French product catalog), then the servlet again falls back to the default repository and tries to find the item with the same ID. This is only useful if the items have the exact same ID in each repository. For example, you might view the site in French and try to look at product 1234. If the ID is defined in the French product catalog, you see the French version of that product. However, if 1234 is not defined, then you see the default English version of product 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 the empty
open parameter is rendered. The same is true if an alternative repository is selected, but the item cannot be found and getDefaultItem
is set to false.
After finding the repository item, the ItemLookupDroplet
servlet bean can perform additional validation to determine if the item is appropriate for the specified site context. Note that site filtering has no effect unless an application has been configured to use multisite, as described in the Multisite Administration Guide.
The following properties configure site filtering for item look-ups:
The
filterBySite
property controls whether site filtering is applied. IffilterBySite
is set totrue
(the default), theItemLookupDroplet
component compares the value of the item property that is named by the associated item descriptor’scontext-membership-property
attribute to one of the following:The IDs of the sites specified by the
sites
input parameter, if it has been defined, orThe current site ID, if the
sites
input parameter is not defined.
If a match is found, the
output
open parameter is rendered. If there is no match, thewrongSite
open parameter is rendered. For the product catalog and content management repositories, thecontext-membership-property
attribute is set to thesiteIds
property for all item descriptors. So, for example, if the returned item’ssiteIds
property is set to Site A, the current site is Site A, and thesites
input parameter is not defined, then the item is rendered.The
sitePropertyName
property allows you to override the value set in thecontext-membership-property
attribute or apply site filtering to items that do not have acontext-membership-property
property defined. ThesitesPropertyName
property specifies the item property that should be compared to determine whether or not the item should be rendered.