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
-
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.
-
In the Enterprise Explorer view, expand 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.
, where For example, if the object belongs to the catalog component, your directory structure can be.
-
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" />
- Within your file, include the element
- Expand .
-
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. -
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. - Restart the WebSphere Commerce Test Server and test your changes.