Creating a new controller JSP file to retrieve and mediate the Management Center object

In this lesson you will create the controller JSP file for your new search definition. The controller JSP file will be used to provide the search service, which will be called by the search definition of the Management Center. The controller JSP file gets the search terms from the user interface as parameters, and then invokes the wcf:getData tag library to retrieve the Noun that is used for the Management Center object. In the wcf:getData tag, the expressionBuilder parameter defines the query template to run when performing the search. Expression builders from the previous lesson are used.

About this task

Each wcfSearchDefinition has an associated wcfSearchService. This service is implemented as a controller JSP file that takes the search terms as parameters, and then invokes the wcf:getData tag library to retrieve the Noun that is used for the Management Center object. In the wcf:getData tag, the expressionBuilder parameter defines the query template to run when performing the search. The query template is mapped with the SQL which will be executed in the database to retrieve the data.

For more information about the Management Center Web Application, refer to Management Center Web application.

To complete a search across warranty columns with different data types, you define different expression builders according to whether the search text is numeric or not.


  1. Open WebSphere Commerce Developer.
  2. In the Enterprise Explorer view, navigate to LOBTools > WebContent > jsp > mycompany > catalog
  3. Right click the catalog folder and select New > Other > Simple > File. In the File name field, type FindAllCatalogEntriesByWarranty.jsp, and then click Finish. The new controller JSP file is created and opened in the default editor.
  4. Add the following sample code to the JSP file:
    <?xml version="1.0" encoding="UTF-8"?>
    <%@ taglib uri="" prefix="c"%>
    <%@ taglib uri="" prefix="wcf"%>
    // Do judgment if the input search text is numeric,
    //if it is, assign expression builder as "findAllCatentriesByWarrantySearchNumeric";
    //if not assign expression builder as "findAllCatentriesByWarrantySearchNonNumeric"
    boolean isNumeric = false;
    String searchText = request.getParameter("searchText");
    if (searchText!=null && !searchText.equals("")){
        try {
            isNumeric = true;
        }catch (NumberFormatException ne){
            isNumeric = false;
    String expressionBuilder = "";
    if (isNumeric){
        expressionBuilder = "findAllCatentriesByWarrantySearchNumeric";
        expressionBuilder = "findAllCatentriesByWarrantySearchNonNumeric";
          <c:when test="${empty param.searchText}">
                       <%-- No search criteria is specified --%>
                        <wcf:getData type="[]"
                                        <wcf:contextData name="storeId" data="${param.storeId}"/>
                                        <wcf:contextData name="catalogId" data="${param.masterCatalogId}"/>
                                        <wcf:param name="warterm" value="${param.searchText}"/>
                                        <wcf:param name="catEntryTypes" value="ProductBean,BundleBean,PackageBean,DynamicKitBean"/>
                                        <wcf:param name="wartype" value="${param.searchText}"/>
                                        <wcf:param name="careinstruction" value="${param.searchText}"/>
                        <jsp:directive.include file="../../commerce/catalog/restricted/serialize/SerializeCatalogEntries.jspf"/>
    • The wcf:getData tag has the following attributes and sub-elements:

      The data type of the data that is to be retrieved. Here you use[] to retrieve CatalogEntry list.
      The name of a configured expression builder, which is defined in the get-data-config.xml file for each component. The Java code near the start of the page determines whether to use findAllCatentriesByWarrantySearchNumeric or findAllCatentriesByWarrantySearchNonNumeric.
      recordSetStartNumber, recordSetReferenceId, maxItems
      The parameters used to support paging.
      The sub-tag to retrieve context information. In this example you are retrieving the storeId and catalogId context information.
      The tag to retrieve parameters value. Four parameters are assigned in this example:
      warterm, wartype, careinstruction:
      The values for these 3 parameters are the same, which is from search input field. You assign these parameters here in order to build your search logic: search all the catalog entries with the warranty information matched with the input value, the warranty information include wartype, warterm and careinstruction.
      The catalog entry types to be retrieved. In WebSphere Commerce Catalog system, there are several catalog entries type, in this search, you will only retrieve those with the type of Product, Bundle, Package and DynamicKit.

      For a detailed description of the wcf:getData tag, see Tag: getData.

    Note: When creating new controller JSP files, you can copy an existing similar controller JSP file and update it with your customization. For example, for the new controller JSP file in this tutorial, a similar file is \LOBTools\WebContent\jsp\commerce\catalog\restricted\FindAllCatalogEntriesExceptSKUs.jsp,. For future projects, you can copy and modify this file to create a new one.
  5. Save and close the file.
  6. Add a new action-mappings configuration to the Struts extension configuration file, to map the action used in wcfSearchService with this new controller JSP:
    1. In the Enterprise Explorer view, navigate to LOBTools > WebContent > WEB-INF the Struts extension configuration file already exists, and is named struts-extension.xml. Double click the file to open it in the default editor.
    2. In the source view of the struts-extension.xml file, add the following line to the action-mappings section:
      <action path="/FindCatalogEntries-ByWarranty" forward="/jsp/mycompany/catalog/FindAllCatalogEntriesByWarranty.jsp" />
    3. Save and Close the file.
    4. Restart the WebSphere Commerce Test Server to load the new configuration