Overriding a retrieve service for a Management Center object

If you need to include more information for an object or change how the information for an object is retrieved, you can override an existing retrieval service. To override the service, create your own custom controller JSP file to retrieve and mediate the Management Center object and register the JSP file within the Spring framework.

Procedure

  1. Identify the Management Center object controller JSP and Spring framework definition that you need to override for the object.
    For example, the following steps identify the controller JSP file that is used by the advanced search feature for retrieving catalog entry objects.
    1. Open IBM WebSphere Commerce Developer.
    2. In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > xml > commerce > catalog > searchDefinitions.
    3. Open the FindAllCatalogEntriesSearchDefinition.xml file and review the file contents. Within the <SearchService>element definition, the value for the URL attribute is "/cmc/FindCatalogEntries-All". This value maps to the Spring <bean> definition that identifies the controller that is invoked by the search service.
      
      <SearchService name="findAllCatalogEntries" url="/cmc/FindCatalogEntries-All">
        <ServiceParam name="storeId"/>
        <ServiceParam name="masterCatalogId"/> 
        <ServiceParam name="defaultLanguageId"/>
      </SearchService>
    4. Expand LOBTools > WebContent > WEB-INF.
    5. Open the spring-ibm-catalog.xml file and review the file contents.
      Within the file, locate the controller configuration that has the id attribute with the value "FindCatalogEntries-All". The configuration can resemble the following code snippet.
      
      <bean id="/FindCatalogEntries-All" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
        <property name="viewName" value="/jsp/commerce/catalog/restricted/FindAllCatalogEntries.jsp"/>
      </bean>
      
      The value for the property "viewName" identifies the controller JSP file for this definition, which is the /jsp/commerce/catalog/restricted/FindAllCatalogEntries.jsp JSP file.
  2. In the Enterprise Explorer view, expand LOBTools > WebContent > jsp > mycompany > component, where mycompany is the name of your company and component is the name of the object component. If the mycompany and component directories do not exist, create the directories.
    For example, if the object belongs to the catalog component, your directory structure can be mycompany > catalog.
  3. Within the component directory, create a JSP file.
    Create a JSP file that determines whether to handle the request or to forward the request to another JSP file. If the request needs to be handled by your new JSP file, your file must define how to handle the request.
    • Within your file, include the element <jsp:directive:include file="" /> to identify the serialization JSP fragment to use to transform the the object into the expected XML representation.
    • The name of your controller JSP file should match the usage of the file. For instance, if the file defines a request to get warranty information for a product, the file name can be GetProductChildren-Warranty.jsp.
    For example, the following code defines a controller JSP file for retrieving warranty information for catalog entries.
    
    <?xml version="1.0" encoding="UTF-8"?>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://commerce.ibm.com/foundation" prefix="wcf"%>
    <%-- Decide which expression builder to call based on the input --%>
    
    <wcf:getData
      type="com.ibm.commerce.catalog.facade.datatypes.CatalogEntryType[]"
      var="catentries" expressionBuilder="findMyCompanyAdvancedSearch" varShowVerb="showVerb"
      recordSetStartNumber="${param.recordSetStartNumber}"
      recordSetReferenceId="${param.recordSetReferenceId}" maxItems="${param.maxItems}">
      <wcf:contextData name="storeId" data="${param.storeId}" />
      <wcf:contextData name="catalogId" data="${catalog}" />
      <wcf:param name="shortDescription" value="" />
      <wcf:param name="mfPartNumber" value="${param.mfPartNumber}" />
      <wcf:param name="mfName" value="${param.manufacturer}" />
      <wcf:param name="groupIdentifier" value="${param.parentCategory}" />
    
      <c:if test="${param.wartermSelection != 'null'}">
        <c:set var="warterm" value="${param.wartermSelection}" />
      </c:if>
      <wcf:param name="wartermSelection" value="${warterm}" />
    
      <c:if test="${param.wartypeSelection != 'null'}">
        <c:set var="wartype" value="${param.wartypeSelection}" />
      </c:if>
      <wcf:param name="wartypeSelection" value="${wartype}" />>
      <wcf:param name="partNumber" value="${catentryCode}" />
      <wcf:param name="name" value="${catentryName}" />
    
      <c:set var="productExp" value="ProductBean" />
      <c:set var="bundleExp" value="BundleBean" />
      <c:set var="kitExp" value="PackageBean" />
      <c:set var="dynamicKitExp" value="DynamicKitBean" />
      <c:set var="SKUExp" value="ItemBean" />
    
      <c:if test="${(empty param.published)}">
        <wcf:param name="published" value="" />
      </c:if>
    
      <c:if test="${param.published == '1'}">
        <wcf:param name="published" value="1" />
      </c:if>
    
      <c:if test="${param.published == '2'}">
        <wcf:param name="published" value="0" />
      </c:if>
    
      <c:if test="${param.published == '3'}">
        <wcf:param name="published" value="" />
      </c:if>
    
      <c:if test="${(empty param.catentryTypes)}">
        <wcf:param name="catEntryTypes"
          value="${productExp},${bundleExp},${kitExp},${dynamicKitExp},${SKUExp}" />
      </c:if>
      <c:if test="${param.catentryTypes == '1'}">
        <wcf:param name="catEntryTypes"
          value="${productExp},${bundleExp},${kitExp},${dynamicKitExp}" />
      </c:if>
      <c:if test="${param.catentryTypes == '2'}">
        <c:set var="typeParam" value="" />
    
        <c:if test="${param.typeProducts == 'true'}">
          <c:if test="${typeParam != ''}">
            <c:set var="typeParam" value="${typeParam}," />
          </c:if>
          <c:set var="typeParam" value="${typeParam}${productExp}" />
        </c:if>
    
        <c:if test="${param.typeBundles == 'true'}">
          <c:if test="${typeParam != ''}">
            <c:set var="typeParam" value="${typeParam}," />
          </c:if>
          <c:set var="typeParam" value="${typeParam}${bundleExp}" />
        </c:if>
    
        <c:if test="${param.typeKits == 'true'}">
          <c:if test="${typeParam != ''}">
            <c:set var="typeParam" value="${typeParam}," />
          </c:if>
          <c:set var="typeParam" value="${typeParam}${kitExp},${dynamicKitExp}" />
        </c:if>
    
        <c:if test="${param.typeSKUs == 'true'}">
          <c:if test="${typeParam != ''}">
            <c:set var="typeParam" value="${typeParam}," />
          </c:if>
          <c:set var="typeParam" value="${typeParam}${SKUExp}" />
        </c:if>
    
        <wcf:param name="catEntryTypes" value="${typeParam}" />
      </c:if>
    
    </wcf:getData>
    <jsp:directive.include file="../../commerce/catalog/restricted/serialize/SerializeCatalogEntries.jspf" />
    
  4. Expand LOBTools > WebContent > WEB-INF.
  5. Open the spring-component.xml file that includes the Spring framework controller configuration that you need to override. Copy the <bean> element configuration from this file.
  6. Open the spring-extension.xml file for editing and add the configuration that you copied into this file. Change the value for the value attribute in the configuration to point to your new JSP files. Your configuration within this extension file override the configurations for the same retrieval services within the Spring component configuration files that are provided by WebSphere Commerce.
  7. Restart the WebSphere Commerce Test Server and test your changes.