Samples >


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:

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:

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"
    value="${orderBean.orderItemDataBeans[0].currentAddressDataBean}"
    />
    

    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="../
    storedir/Snippets/ReusableObjects/AddressDisplay.jspf"
    %>
    


Related concepts

Samples gallery

Related reference

WebSphere Commerce JSP programming best practices

JSP object snippet: AddressDisplay.jspf

JSP object snippet: AddressEntryFormDisplay.jspf

JSP object snippet: CatalogEntryPriceDisplay.jspf

JSP object snippet: CatalogEntryThumbnailDisplay.jspf

JSP object snippet: NameEntryFormDisplay.jspf


+

Search Tips   |   Advanced Search