To override a default WebSphere Commerce expression
builder, you must create a new expression builder with the same name
in a custom get-data-config.xml.
About this task
The expression builder is used by the wcf:getData tag
in the controller JSP file to construct an XPath expression that is
used by a custom service to retrieve data. All expression builders
are defined in the get-data-config.xml file. To extend the advanced
search with the new warranty term and warranty type criteria, you
must extend the expression builder with the new query template and
include the new criteria in the query. The base get-data-config.xml
file for each component can be located in \LOBTools\WebContent\WEB-INF\config\com.ibm.commerce. component \get-data-config.xml .
You cannot directly modify this file. Instead, create the \LOBTools\WebContent\WEB-INF\config\com.ibm.commerce. component -ext
extension folder to store the extended get-data-config.xml file. The
extension folder and the extended get-data-config.xml file were already
defined in .
In this tutorial, you only need to open the extended get-data-config.xml
file and add the new expression builder definition to the file.
Next,
you need to extend the findAllCatentriesAdvancedSearch expression
builder.
Procedure
Extending the advanced search expression builder
with new parameters
Modify the value of the template to
add the warranty type and warranty term conditions. Extend the search
method of the query template to include new conditions. For more information
about the search method, see the search() function section in the Parametric search support
topic.
- Locate the base advanced search expression builder, which
you will replace with your extended expression builder.
- Navigate to the \LOBTools\WebContent\jsp\mycompany\catalog\FindAllCatalogEntries.jsp
file. Double-click the extended controller JSP file to open it in
the default editor.
- In the wcf:getData section, the expressionBuilder
property is used to assign the search expression builder. In this
controller JSP file, the expressionBuilder is set dynamically under
different conditions if certain search conditions are empty. There
are three expression builders under different conditions:
- findAllCatentriesBasicSearch - When the search is invoked in
the base search, but not in the Advanced Search dialog
- findAllCatentriesByParentCatgroupAdvancedSearch - When all of
the conditions except Category are empty
- findAllCatentriesAdvancedSearch - When any of the conditions
except Category are not empty
- Extend the findAllCatentriesAdvancedSearch expression
builder. Modify the value of the template to add the warranty type
and warranty term conditions. Extend the search method of the query
template to include new conditions. For more information about the
search method, see the search() function section in the Parametric search support
topic.
-
Navigate to \LOBTools\WebContent\WEB-INF\config\com.ibm.commerce.catalog
and double-click the base get-data-config.xml file to open it in the default
editor. Locate the
findAllCatentriesAdvancedSearch
expression builder definition
and copy the section between the <expression-builder>
and
</expression-builder>
elements, including the tags.
-
Navigate to
\LOBTools\WebContent\WEB-INF\config\com.ibm.commerce.catalog-ext and
double-click the extended get-data-config.xml file to open it in the default
editor. This file was created in Tutorial: Adding fields in the Catalogs tool .
- Paste the content copied from the base get-data-config.xml
file into the extended get-data-config.xml file, before the
"</wcf:get-data-config>
"
line at the end of this file.
- Update the new findAllCatentriesAdvancedSearch expression
builder:
- Change the name of the expression builder from findAllCatentriesAdvancedSearch
to findMyCompanyAdvancedSearch.
- Change the template value to add the new search conditions of Warterm and
Wartype:
<value>
/CatalogEntry[($catEntryTypes$) and search(CatalogEntryIdentifier/ExternalIdentifier/PartNumber='$partNumber$' and Description/Name='$name$'
and Description/ShortDescription='$shortDescription$' and Description/Attributes/published='$published$' and CatalogEntryAttribute/Attributes/mfPartNumber='$mfPartNumber$'
and CatalogEntryAttribute/Attributes/mfName='$mfName$' and
UserData/UserDataField/Warterm='$wartermSelection$'
and
UserData/UserDataField/Wartype='$wartypeSelection$'
) and ParentCatalogGroupIdentifier[ExternalIdentifier[GroupIdentifier='$groupIdentifier$']]]</value>
- Change the access profile from IBM_Admin_Details to MyCompany_All.
Note: IBM_Admin_ prefixes
all services intended to be used by admin/CMC based services calls. Access profiles which do not
follow the naming conventions continue to function correctly, as compatibility is maintained with
earlier versions. It is recommended, however, that they are followed for existing access profiles,
and when making changes to future access profiles.
The following code shows the extended expression-builder:
<?xml version="1.0" encoding="UTF-8"?>
<wcf:get-data-config
xmlns:wcf="http://www.ibm.com/xmlns/prod/commerce/foundation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation ../../xsd/get-data-config.xsd ">
<expression-builder>
<name>
getCatalogEntryDetailsByParentCatalogGroupId</name>
<data-type-name>
CatalogEntry</data-type-name>
<param>
<name>
accessProfile</name>
<value>
MyCompany_All</value>
</param>
</expression-builder>
<expression-builder>
<name>
findMyCompanyAdvancedSearch</name>
<data-type-name>
CatalogEntry</data-type-name>
<class>
com.ibm.commerce.catalog.internal.client.taglib.util.CatalogSearchExpressionBuilder</class>
<method>
formatExpression</method>
<param>
<name>
template</name>
<value>
/CatalogEntry[($catEntryTypes$) and search(CatalogEntryIdentifier/ExternalIdentifier/PartNumber='$partNumber$'
and Description/Name='$name$' and Description/ShortDescription='$shortDescription$' and Description/Attributes/published='$published$'
and CatalogEntryAttribute/Attributes/mfPartNumber='$mfPartNumber$' and CatalogEntryAttribute/Attributes/mfName='$mfName$'
and UserData/UserDataField/Warterm='$wartermSelection$' and UserData/UserDataField/Wartype='$wartypeSelection$')
and ParentCatalogGroupIdentifier[ExternalIdentifier[GroupIdentifier='$groupIdentifier$']]]</value>
</param>
<param>
<name>
accessProfile</name>
<value>
MyCompany_All</value>
</param>
<param>
<name>
searchType</name>
<value>
catentry-advanced</value>
</param>
</expression-builder>
</wcf:get-data-config>
Notes:
- The extended template uses the UserData/UserDataField/Warterm and
UserData/UserDataField/Wartype property, defined in the extended wc-component.xml file in Configuring parametric search to search on custom data .
- The accessProfile is modified from
IBM_Admin_Details
to
MyCompany_All
. This new accessProfile is used to extend the query to return the result
with the new warranty type and warranty term properties. The accessProfile was defined in the
\xml\config\com.ibm.commerce.catalog-ext\wc-query-MyCompanyCatalogEntry-get.tpl file in
.
- Click Save .
- Restart the WebSphere Commerce Test Server to load new
configuration.