The getRepositoryItemIdentifier() JavaScript function from <ATG10dir>/WebUI/preview/preview_tagging.js library returns a class for a repository item based on a repository name, item descriptor name and repository ID.

Example

The following Commerce Reference Store widgets display the results of searching or sorting:

These widgets include three JSON properties (repository, itemDescriptor, and ID) that are used in the Product Listing widget (store.war/javascript/widget/ProductListing.js) to create the class.

<%-- PRODUCT REPOSITORY NAME --%>
<json:property name="repository">
   <dsp:getvalueof var="repositoryName" scope="page"
param="product.repository.repositoryName"/>
   <c:out value="${repositoryName}" escapeXml="false"/>
</json:property>

<%-- PRODUCT ITEM DESCRIPTOR --%>
<json:property name="itemDescriptor">
   <dsp:getvalueof var="itemDescriptor" scope="page"
param="product.itemDescriptor.itemDescriptorName"/>
   <c:out value="${itemDescriptor}" escapeXml="false"/>
</json:property>

<%-- PRODUCT ID --%>
<json:property name="id">
   <dsp:getvalueof var="prodId" param="product.id" />
   <c:out value="${prodId}" escapeXml="false"/>
</json:property>

The Product Listing widget uses the getRepositoryItemIdentifier() function to create the class. The updatePreview() method, called at the end of the handleJSON function binds the Visual Merchandising menu to the class string.

HandleJSON:funcion(prodObj){

dojo.forEach(itemArray, function(item, index, itemArray){
     var classString = getRepositoryItemIdentifier(item.repository,
item.itemDescriptor, item.id);
        item.previewClassString = classString;
. . .
   }
updatePreview();
}

The class string is inserted in the Product View widget (ProductView.js):

    templateString: '<li class="${previewClassString}">
<a href="${productURL}">
<span class="atg_store_productImage">
<img src="${productImage}" alt="${productImageTitle}" />
</span>
<span class="atg_store_productTitle">${productTitle}</span>
<span class="atg_store_productPrice">${productPrice}</span>
<span class="siteIndicator" dojoAttachPoint="productSiteIcon"></span>
</a>
</li>',

The class string is initialized with data passed from HandleJSON:funcion(prodObj) from store.war/javascript/widget/ProductListing.js.

this.previewClassString=this.data.previewClassString;