Object snippets

WebSphere Commerce object snippets are reusable pieces of JSP code that represent display properties of business objects, such as an address, a price, or a catalog entry.

Among the chief benefits of using object snippets are the following:

  • Smaller and more compact JSP pages
  • Faster time to value achieved through reuse of object snippets on user-created store pages
  • Single point of change for the object display, which ensures consistency across store pages

All of the WebSphere Commerce object snippets for the consumer direct sample storeand the B2B direct starter store are provided as JSPF files located in the following directory:

  • For IBM i OS operating systemSolarisLinuxAIXWindows WC_eardir/Stores.war/ storedir/Snippets/ReusableObjects
  • WebSphere Commerce Developer workspace_dir\Stores\Web Content\ storedir\Snippets\ReusableObjects

Object snippets must be included into top-level JSP pages (also known as content panels) by means of static includes. Each object snippet expects certain variables to be declared on the including page. These variables are clearly identified in the snippet's introductory comment.

As an illustration of object snippet use, consider the common task of displaying an address on a store page. With the help of the address display object snippet, AddressDisplay.jspf, enabling the display of an address at a new location within a store can be accomplished in two easy steps:

  1. Declare a variable named address and assign it an AddressDataBean data bean, as instructed in the address display object snippet's introductory comment. For example:
    <c:set var="address"

    where orderBean.orderItemDataBeans[0].currentAddressDataBean is the AddressDataBean data bean that provides the shipping address associated with the first item in the order.

  2. Include the address display object snippet by means of a static include such as the following:

    <%@ include file="../