Customizing storefront JSP pages using the getData tag

JSP files can retrieve and display information from WebSphere Commerce services using the getData tag.

Before you begin

About this task

Tip: The starter store pages, such as Consumer Direct JSP files, use the data bean programming model for data retrieval. For example, existing starter store pages, such as ProductDisplay.jsp, do not use the getData tag. However, you can add getData tags to these pages retrieve additional information from your WebSphere Commerce services.

Procedure

  1. Open WebSphere Commerce Developer.
  2. In the Enterprise Explorer view, navigate to Stores > WebContent > Store Name. Continue navigating to the subfolder where the JSP file you want to customize is located.
  3. Locate the section of the page where you want to retrieve data, and add a getData tag, similar to the following example.

    In this example, the getData tag populates a variable named catentries with the data returned by a custom expression builder named getCatalogEntryWithWarranty. The custom access profile MyCompany_All is provided as a parameter to control the amount of data that is returned about each object.

    <wcf:getData var="catentries" type="com.ibm.commerce.catalog.facade.datatypes.CatalogEntryType[]" 
                 expressionBuilder="getCatalogEntryWithWarranty">
    <wcf:contextData name="storeId" data="${WCParam.storeId}"/>
    <wcf:contextData name="catalogId" data="${WCParam.catalogId}"/>
    <wcf:contextData name="langId" data="${WCParam.langId}"/>
    <wcf:param name="catalogEntryId" value="${WCParam.catalogEntryID}"/>
    <wcf:param name="accessProfile" value="MyCompany_All"/>
    </wcf:getData>
    
    For reference information about the getData tag, see Tag: getData.
  4. Optional: If the getData tag returns a collection of objects, you can iterate over them using a forEach loop tag, similar to the following example:
    <c:forEach var="catalogEntry" items="${catentries}">
    <!-- present details about each catalogEntry object in catentries -->
    </c:forEach>