Tutorial: Extending simple search in the Catalogs tool
This tutorial shows how to extend simple search in the Catalogs tool in the IBM Management Center for WebSphere Commerce. Simple search is a function performed in the search widget of the Management Center, which provides the capability to search on a single property – such as the price or size of a product. The current Catalogs tool provides several simple searches such as search catalog entries by name, and search category by name. In this tutorial, we will provide search on catalog entries by warranty term, warranty type and care instruction.
In this tutorial module, we will use the data service layer to generate the parametric Simple catalog search search queries for you. The queries are specified using configuration files called query template files. This is an appropriate query method for developers who do not want to write their own SQL.
This tutorial is the continuation of Tutorial: Adding new fields in the Catalogs tool and Tutorial: Adding new search conditions in the advanced search of the Catalogs tool. You will continue customizing the Management Center, to perform cross-column (on 3 columns, spread over 2 tables) wildcard searches on warranty and care instruction information of catalog entries and catalog entry descriptions. This information is stored in different columns of 2 tables: XWARRANTY and XCAREINSTRUCTION. These tables are created in Tutorial: Adding new fields in the Catalogs tool.
The following diagram outlines the schema-related warranty information. The columns for wildcard search are marked with red underline.
Extend simple catalog search consists of two steps:
- Extend the DSL configuration to support searches on the data in the new custom tables.
- Extend the search widget in Catalogs tool to include the new search definition, so that it will send the new XPath queries to the server for processing
To create a new search definition, see Changing the search definition for a Management Center object.
As a result of the extension, the new search widget will look like the following screen capture, in which "All Catalog Entries By Warranty" is added:
In this tutorial, the DSL is used to generate the parametric search SQL. If you do not want DSL to generate parametric search SQL, you can override this behavior. For more information, see Overriding generated parametric search SQL.
Learning objectives
After completing this tutorial you should be able to:
- Configure parametric search to include custom tables
- Update the search widget in the Catalogs tool to include new search definition
- Create a new controller JSP file to retrieve and mediate the Management Center object
- Create a new ExpressionBuilder in get-data-config.xml to invoke the new query and pass query parameters.
Time required
Expect this tutorial to take about two hours to complete.
You can download the completed tutorial code for this tutorial for the reference:
- Download the completed tutorial code for WebSphere Commerce v7 and Feature Pack 1.
- Download the completed tutorial code for WebSphere Commerce v7 Feature Pack 2.
However, in order to fully attain the learning objectives, it is recommended that you perform the tutorial step-by-step.
Skill level
Advanced
Audience
This tutorial is intended for WebSphere Commerce developers responsible for creating and customizing WebSphere Commerce SOA services and customizing the Management Center user interface.
System requirements
Before beginning this tutorial ensure that you have:
- Enabled the management-center feature
- Created a Category Manager
- Completed the following tutorials:
- Tutorial: Adding new properties to a WebSphere Commerce service using the data service layer
- Tutorial: Adding new fields in the Catalogs tool
- Tutorial: Adding new search conditions in the advanced search of the Catalogs tool
Prerequisites
To complete this tutorial you should have a basic understanding of:
- WebSphere Commerce Developer
- The Management Center for WebSphere Commerce programming model
- The OpenLaszlo programming API to extend the wcfSearchDefinition class
- The Java programming language
- GetData tag configuration
- JSP pages
- HTML
- XML
- Struts configuration
Lessons in this tutorial
- Configure parametric search for custom data
In this lesson you reuse existing Catalog queries to perform the searches on the warranty data.
- Create a new expression builder in the get-data-config.xml file
In this lesson, we will define two new expression builders in get-data-config.xml to process the search. These expression builders will be used on the controller JSP file. The first expression builder is used for numeric input search text, and the second one is used for non-numeric input search text.
- Create a new controller JSP file to retrieve and mediate the Management Center object
In this lesson we will create the controller JSP file for the 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.
- Create new resource bundles for custom text strings
In the Management Center, all text labels and images are registered as resource bundles, and the strings of the text labels are defined in a property file. In this lesson, you create and register the text label for the display name of the new simple search.
- Define the new search definition by extending the wcfSearchDefinition class
This lesson introduces how to extend the search widget in the Management Center to display the new search option, and how to define the new search definition by extending the wcfSearchDefinition class. In the Management Center, all search options are defined by extending this class. All properties and methods are predefined, you can use them directly to define the search.
- Add the new search definition into the Search Widget in the Catalogs tool
After defining the new search definition, add it into the search widget of the Catalogs tool as a new search option. There are several existing search options in the current Catalogs tool, such as All Catalog Entries Except SKU, All Catalog Entries, Categories, Products.
- Test the customizations
In this lesson, you perform two test cases to verify the customizations performed in this module.
- Deploy the customizations
Once you complete and test the customization, you are ready to deploy the custom code to a target WebSphere Commerce Server to make the new function available to the business users. Deploying to the server involves exporting code from the WebSphere Commerce development environment and deploying code into the target WebSphere Commerce Server.