Overriding a retrieve service for a Management Center object
To override an existing retrieve service, create a new controller JSP page and a new Struts action forward.
About this task
Procedure
- Identify the Management Center object read operation to
override by identifying the Management Center service operation to
override. Use the naming convention to identify the Struts action
forward and the controller JSP file.For example, to identify which controller JSP file is used by the Catalog Entry Advanced Search:
- Complete one of the following steps:
- Open the
Catalog Entry Search definition
class. This class was in the FindAllCatalogEntriesSearchDefinition.lzx file in Extending the Advanced Search dialog to include extended properties as search. - Open the
Catalog Entry Search definition
. This definition was in the FindAllCatalogEntriesSearchDefinition.def file in Extending the Advanced Search dialog to include extended properties as search.
- Open the
- Complete one of the following steps:
- In the wcfSearchService
section, specify the value of the URL property:
url="/cmc/FindCatalogEntries-All"
. The URL property means that the Struts action is invoked by the search service. - In the SearchService
section, note the value of the URL attribute:
url="/cmc/FindCatalogEntries-All"
. This is the Struts action that is invoked by the search service.
- In the wcfSearchService
section, specify the value of the URL property:
- Navigate to LOBTools > WebContent > WEB-INF and double-click one of the following files to open
it in the default editor:
- struts-ibm-tools.xml
- struts-ibm-catalog.xml
Note: Do not change this XML file since it might be replaced in a fix pack. - Locate the action definition in the action-mappings
section by searching for
FindCatalogEntries-All
. The search result is:<!-- Catalog Tool Search Definitions --> <!-- ========= --> <action path="/FindSKUs" forward="/jsp/commerce/catalog/restricted/FindSKUs.jsp" /> <action path="/FindKits" forward="/jsp/commerce/catalog/restricted/FindKits.jsp" /> <action path="/FindDynamicKits" forward="/jsp/commerce/catalog/restricted/FindDynamicKits.jsp" /> <action path="/FindBundles" forward="/jsp/commerce/catalog/restricted/FindBundles.jsp" /> <action path="/FindProducts" forward="/jsp/commerce/catalog/restricted/FindProducts.jsp" /> <action path="/FindSalesCategories" forward="/jsp/commerce/catalog/restricted/FindSalesCategories.jsp" /> <action path="/FindCatalogEntries-ExceptSKUs" forward="/jsp/commerce/catalog/restricted/FindAllCatalogEntriesExceptSKUs.jsp" /> <action path="/FindCategories-All" forward="/jsp/commerce/catalog/restricted/FindAllCategories.jsp" /> <action path="/FindCatalogEntries-All" forward="/jsp/commerce/catalog/restricted/FindAllCatalogEntries.jsp" /> <action path="/FindCatalogs" forward="/jsp/commerce/catalog/restricted/FindCatalogs.jsp" />
- The search result for
FindCatalogEntries-All
indicates that the controller JSP file to be extended is /jsp/commerce/catalog/restricted/FindAllCatalogEntries.jsp.
- Complete one of the following steps:
- Open WebSphere Commerce Developer.
- Navigate to the LOBTools project.
- Create a new directory under the WebContent/jsp directory
to contain the customized JSP files. For example,
WebContent/jsp/myComponent
. - Create a JSP file that determines whether to handle the
request or to forward it to the IBM-supplied JSP file. If the JSP
file determines that the request should be handled, it must also specify
how to handle the request.For example:
- Navigate to LOBTools > WebContent > jsp.
- To create the JSP extension folder, right-click jsp and select New > Folder.
- In the Folder name field, type mycompany, click Next, and then click Finish.
- In the mycompany directory, create a folder that is called catalog.
- To create the extension controller JSP file, right-click the catalog folder and select New > File.
- In the File name field, type FindAllCatalogEntries-WithWarrentyCriteria.jsp, and then click Finish.
- Copy the following code into the FindAllCatalogEntries-WithWarrentyCriteria.jsp file:
<?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" />
Note: The JSP file uses the new expression Builder, findMyCompanyAdvancedSearch, to get data that is defined later in the Creating a new expression builder to override a default expression builder step.
- Implement the new get-data expression and forward to the existing serialization JSP file.
- Navigate to the WebContent/WEB-INF directory and open one
of the following files:
- struts-ibm-tools.xml
- struts-ibm-catalog.xml
- Copy the Struts action forward configuration to the struts-extension.xml file and update the Struts action forward path attribute to point to the new controller JSP page.
- Deploy your changes to your production environment.