In the previous step of this tutorial, Defining the new Commerce Enabled Portal portlet, you defined the new Product Information Display portlet.
In order for the tutorial scenario of a customer selecting a product in a shopping cart portlet and displaying the product information in the product information display portlet to work, you must edit the ProductOnlyDisplay.jsp file to work with the sample JSP file, ProductInfo.jsp. ProductInfo.jsp is provided with the sample download package. (It is located in the ZIP file in Sample3\ProductInfo.jsp).
To edit the ProductOnlyDisplay.jsp file, do the following:
- Ensure you have downloaded the sample code package from Commerce Enabled Portal tutorials sample code.
- After downloading the sample code package, locate the following file: Samples\Sample3\ProductInfo.jsp.
- Copy the sample ProductInfo.jsp to the following location on your WebSphere Commerce development environment machine:
- WCDE_installdir\workspace\Stores\Web Content\Winstons\portal_jsp\ShoppingArea\CatalogSection\CatalogEntrySubsection
- If the Commerce Enabled Portal development environment is not already open then open it.
Note: If the WebSphere Commerce development environment is already open, you will need to refresh it before you will see the new file.- From the Start menu, select Programs > IBM WebSphere Commerce Developer Enterprise > WebSphere Commerce development environment.
- Start the WebSphere Commerce Test Server.
- At the bottom of the window, click Servers
- Select the WebSphere Commerce Test Server. Right click. From the menu, select Start.
- After the server starts, do the following:
- From the Window menu, select Open Perspective > Web.
- Open the ProductOnlyDisplay.jsp file.
- In the Project Navigator, expand Stores > Web Content > Winstons > portal_jsp > ShoppingArea > CatalogSection > CatalogEntrySubsection. ProductOnlyDisplay.jsp. ProductOnlyDisplay.jsp opens in the main pane.
- Find the following parameter:
String origin = jhelper.getParameter ("origin");
- Directly after the String origin line, add the following parameter:
String productInfo = jhelper.getParameter("productInfo");
if (productInfo!= null)
{
%>
<jsp:include page="ProductInfo.jsp" flush="true">
</jsp:include>
<%
} else {
This parameter allows the ProductOnlyDisplay.jsp to include the sample ProductInfo.jsp into the file. As a result when a customer clicks on the product in the shopping cart portlet, the ProductOnlyDisplay.jsp is called. ProductOnlyDisplay.jsp then includes the ProductInfo.jsp page, and displays the results.
- Find the following code:
catch (Exception e)
It should be near the end of the file. - Add a } before the catch (Exception e)
- Save your changes.
- Now you must update the OrderItemDisplay.jsp page. Currently when a customer clicks on the product in the shopping cart, the product information is displayed in the shopping cart portlet. However, we want the product information to be displayed in the product information portlet. As a result you must edit the link in OrderItemDisplay.jsp. To edit the link:
- Open WCDE_installdir\workspace\Stores\Web Content\Winstons\portal_jsp\ShoppingArea\ShopcartSection\OrderItemDisplay.jsp
- Search for <%=orderItem.getCatalogEntry().getDescription
- Change the href value to the following: <wcep:linkencoder>ShopcartCalculateView?URL=OrderItemDisplay&storeId=<%=storeId%>&langId=<%=languageId%> &catalogId=<%=catalogId%>&productId=<%=CatalogEntryId%>&orderId=*&origin=shoppingCart</wcep:linkencoder>
- Save your changes.
- Continue the tutorial by completing the steps in Defining the dynamic context relationship.