We used ProductLookup, a component that is an instance of ItemLookup, to fetch product attributes from the repository on the template pages. This is the beginning of the code from a template page where we used the ProductLookup component:

Note: The “. . .” markers in the following code sample indicate a place where code has been removed to clarify the sample.

<dsp:droplet name="/atg/commerce/catalog/ProductLookup">

  <%--
    *ProductLookup expects an "id" param, but because we already
    *have a page level "id" param, we don't need to pass it in
    *here.
  --%>

  <dsp:param bean="/OriginatingRequest.requestLocale.locale"
       name="repositoryKey"/>
  <dsp:param name="elementName" value="Product"/>
  <dsp:oparam name="output">

. . .
    <dsp:valueof param="Product.displayName"/>

. . .
  </dsp:oparam>
</dsp:droplet>

ProductLookup takes an id parameter as input. It then binds the Product 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 code inside the output parameter section of ProductLookup simply refers to the Product parameter when it needs to access the product’s property values.

The following code shows how we displayed the product’s longDescription property, or, a default value if the product does not have a longDescription property value:

<!-- Display the Product description here: -->
<dsp:valueof param="Product.longDescription">
  This product doesn't have a longDescription yet...
</dsp:valueof>

The following code example shows how we displayed the product’s image. Note that we used the getvalueof tag of the DSP tag library expose a scripting variable to use for the product image:

<dsp:getvalueof id="smallImageUrl" param="Product.smallImage.url"
                idtype="java.lang.String">
   <dsp:img src="<%=smallImageUrl%>"/>
</dsp:getvalueof>
 
loading table of contents...