Creating a new expression builder

An expression builder is used by the wcf:getData tag on a JSP file to construct an XPath expression that is used by a WebSphere Commerce service to retrieve data.

About this task

All expression builders are defined in the get-data-config.xml file. The base get-data-config.xml file for each WebSphere Commerce service module is located in \LOBTools\WebContent\WEB-INF\config\\get-data-config.xml. You cannot modify this file directly. Instead, create the \LOBTools\WebContent\WEB-INF\config\ extension folder to store the extended get-data-config.xml file.


  1. Open WebSphere Commerce Developer.
  2. All new expression builders must be added to a custom get-data-config.xml file. Do not modify default WebSphere Commerce files. If you have not already created a get-data-config file:
    1. In the Enterprise Explorer view, navigate to LOBTools > WebContent > WEB-INF > config.
    2. Right-click config then click New Folder.
    3. In the Folder name, the text is dependent on whether you are working with your own service module or a default WebSphere Commerce service module:
      • For default WebSphere Commerce service modules, use For example,
      • For your own custom service modules, use the custom service module name. No "-ext" suffix is required. For example, com.mycompany.commerce.tutorialstore
    4. Click Finish.
    5. Right-click the new folder then click New > Other > Simple > File > Next.
    6. In the File name field, enter get-data-config.xml.
    7. Click Finish. The get-data-config.xml file opens.
    8. Copy the following elements to the custom get-data-config.xml, to start the file:
      <?xml version="1.0" encoding="UTF-8"?>
      xsi:schemaLocation=" ../../xsd/get-data-config.xsd ">
      <!-- Define data types here -->
      <!-- Define client facades here -->
      <!-- Define expression builders here -->
      All expression builder code is added between the these tags.
  3. If your expression builders use any custom data types, you must include a <data-type> and <client-facade> element to instruct the expression builder how to work with your data. The <data-type> element defines the Java class of your custom data type, and the <client-facade> element defines the class, and method to call on that class, to retrieve the objects.
  4. In the file editor, add one or more expression builders. An example expression builder that performs Catalog search is provided below as an example:
    			/CatalogEntry[(@catalogEntryTypeCode='$catEntryTypes$') and search(UserData/UserDataField/Warterm='$warterm$' or contains(UserData/UserDataField/Wartype,'$wartype$') or contains(Description/Attributes/careinstruction,'$careinstruction$'))]
    The meanings of the XML elements are described in the following list:
    The name of the expression builder. The wcf:getData tag in the controller JSP file refers to this name.
    The name of the data type with which this expression builder definition will be associated. In the example the expression builder is defined for a search that is associated with CatalogEntry
    The fully qualified Java class name of the expression builder. The default is used in the example for Catalog search.
    The method name of the expression builder. This method must accept a java.util.Map and return an instance of The default is used in the example.
    The param element is used to declare parameters that are expected by the expression builder. It is assigned by name and value These child nodes define a parameter to be passed to the query template file.
    The search template used to generate the XPath key and locate the SQL statement in the query template file.
    Each expression builder is associated with a specific Access Profile. This Access Profile, together with the XPath query defined above, uniquely identifies a query in the query template file.
    Note: The data service layer has a specialized convention for UserData in the search mapping, as /UserData/UserDataField/Warterm is not valid XPath. This notation is used to represent the value of the Warterm and Wartype attributes in the UserData field in the example.
  5. Save and close the file.