Develop > Presentation layer > Work with JSP pages
Customize 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
- Identify a custom or default WebSphere Commerce service you want to use to retrieve data.
- Identify the custom or default expression builder to be used with the service, or create a new expression builder.
- Identify the storefront page to customize. If necessary, create and register a new JSP file.
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 the WebSphere Commerce services.
Procedure
- Open WebSphere Commerce Developer.
- In the Enterprise Explorer view, navigate to Stores > WebContent > Store Name. Continue navigating to the subfolder where the JSP file to customize is located.
- Locate the section of the page where 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.
- 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>