You can use servlet beans in your catalog pages to display a list of all of the child categories and child products of a category. For example, the grocery store’s Fruit page might list many different fruit products (Apples, Pears), as well as child categories (Citrus Fruit). When a user clicks on the name of a product on this page, your sites display that product. When a user clicks on the name of a category, your sites display a list of that category’s child categories and child products.

The following example shows a portion of a JSP that renders the displayName property of each child category and child product of the current category. Each of these values is rendered as a link to the corresponding item. The current category’s repository ID is passed to this page (via the itemId parameter) from the page that links to it:

<dsp:droplet name="/atg/commerce/catalog/CategoryLookup">
<dsp:param param="itemId" name="id"/>

<dsp:oparam name="output">
     <dsp:droplet name="/atg/dynamo/droplet/ForEach">
     <dsp:param param="element.childCategories" name="array"/>
     <dsp:oparam name="outputStart">
     <p><b>Child Categories:</b>
     <ul>
     </dsp:oparam>
     <dsp:oparam name="output">
     <li><dsp:getvalueof id="a24" param="element.template.url"
              idtype="java.lang.String">
<dsp:a href="<%=a24%>">
     <dsp:valueof param="element.displayName"/>
     <dsp:param param="element.repositoryId" name="itemId"/>
     </dsp:a></dsp:getvalueof></li>
     </dsp:oparam>
     <dsp:oparam name="outputEnd">
     </ul>
     </dsp:oparam>
   </dsp:droplet>

   <dsp:droplet name="/atg/commerce/catalog/ForEachItemInCatalog">
     <dsp:param param="element.childProducts" name="array"/>
     <dsp:oparam name="outputStart">
     <p><b>Child Products:</b>
     <ul>
     </dsp:oparam>
     <dsp:oparam name="output">
     <li><dsp:getvalueof id="a61" param="element.template.url"
              idtype="java.lang.String">
<dsp:a href="<%=a61%>">
     <dsp:valueof param="element.displayName"/>
     <dsp:param param="element.repositoryId" name="itemId"/>
     </dsp:a></dsp:getvalueof></li>
     </dsp:oparam>
     <dsp:oparam name="outputEnd">
     </ul>
     </dsp:oparam>
   </dsp:droplet>
</dsp:oparam>
</dsp:droplet>

Copyright © 1997, 2012 Oracle and/or its affiliates. All rights reserved. Legal Notices