We used /atg/commerce/catalog/ProductLookup
, a component that is an instance of atg.commerce.catalog.custom.CatalogItemLookupDroplet
class, to fetch product attributes from the repository. This is the beginning of the code from product.jsp
where we used the ProductLookup
component:
<dsp:droplet name="/atg/commerce/catalog/ProductLookup"> <dsp:oparam name="output"> … <table border=0 cellpadding=4> <tr> <td> <span class=categoryhead> <dsp:valueof param="element.displayName">No name</dsp:valueof></span> <br> <b><dsp:valueof param="element.description"/></b></td> </td> </tr> <tr valign=top> <td> <dsp:include page="../common/FormError.jsp" flush="false"></dsp:include> <dsp:droplet name="IsEmpty"> <dsp:param name="value" param="element.largeImage.url"/> <dsp:oparam name="false"> <dsp:getvalueof id="imageURL" param="element.largeImage.url" idtype="java.lang.String"> <dsp:img hspace="70" alt="Product image" src="<%=imageURL%>"/> </dsp:getvalueof> </dsp:oparam> </dsp:droplet> <dsp:getvalueof id="pval0" param="element"><dsp:include page="SKUProperties.jsp" flush="false"><dsp:param name="product" value="<%=pval0%>"/></dsp:include></dsp:getvalueof> <br> <span class=smallb>Product Description</span><br> <span class=small><dsp:valueof param="element.longDescription"> No description</dsp:valueof> </span> </td> </tr> </table> … </dsp:oparam> </dsp:droplet>
ProductLookup
takes an id
parameter as input; in this case, it is the repository ID of the product, from the product link the user clicked on the category page. It then binds the element
parameter to the product with the id
that was passed in. In this code example, we didn’t explicitly pass the id
parameter to the ProductLookup
component. The page-level id
parameter was already defined at the top of the page as an input parameter and thus implicitly passed to ProductLookup
.
The following code shows how we displayed the product’s longDescription
property, or, a default value if the product does not have a longDescription
value:
<dsp:valueof param="element.longDescription">No description</dsp:valueof>
The following code example shows how we displayed the product’s image if it is not null.
<dsp:droplet name="IsEmpty"> <dsp:param name="value" param="element.largeImage.url"/> <dsp:oparam name="false"> <dsp:getvalueof id="imageURL" param="element.largeImage.url" idtype="java.lang.String"> <dsp:img hspace="70" alt="Product image" src="<%=imageURL%>"/> </dsp:getvalueof> </dsp:oparam> </dsp:droplet>