You can modify the search testing UI to add an “Advanced Inputs” section that contains your custom search testing inputs. This allows you to test searches using properties that are not included in the default search testing configuration. When you save a search test, the value of your input is automatically saved as long as it follows the format provided in the default advancedIputs.jsp
file.
Note: ATG does not support changes to the out-of-the-box search test inputs.
This topic contains the following information:
The following figure illustrates how custom inputs appear in search testing:
Steps to Add an Input to Search Testing
To add an input to search testing:
Create an application module for your customizations. See Creating a New Application Module in the ATG Programming Guide.
ATG recommends that you create a new module to ensure that you always have a working application and to avoid issues when you upgrade.
If the input you are adding requires a change to the search query request, for example, a date range input that narrows the search results by availability date, you must extend the form handler class used by the
atg/search/web/assetmanager/SearchTestingFormHandler
component, as follows:Create a subclass of the underlying form handler class,
atg.search.web.assetmanager.CommerceSearchTestingFormHandler
located inDCS-UI.Search
.In the subclass, override the
preSearch
method of the class to implement the search request logic required for your custom search test inputs.See Sample Search Testing Form Handler Subclass for sample code that you can use as a starting point.
Copy the
advancedInputs.jsp
file to your module and give it a custom name, such asmyAdvancedInputs.jsp
. The file is located in theDCS-UI.Search
module at:<ATG9dir>/DCS-UI9.3/DCS-UI/Search/j2ee-apps/DCS-UI-Search.ear/
DCS-UI-Search.war/searchTesting/input
Edit the JSP file to add your custom inputs. Sample code is provided in the default
advancedInputs.jsp
file as a starting point.See Sample Advanced Inputs JSP for an example.
Override the
SearchTestingFormHandler
component to update thepageConfigMap
property with your new JSP file. There are two things you must specify in the mapping:The name and location of the new JSP file
The web application context root for the file (the context identifies your web application so the DSP include can include that file)
The following shows an example of the
pageConfigMap
property with an updated advanced inputs JSP file:pageConfigMap+=\
advancedInputsPage=/custom/myAdvancedInputs.jsp,\
advancedInputsContext=DCS-UI-Search,\
For more information about overriding a component, see the ATG Programming Guide.
In your
SearchTestingFormHandler
component, update the$class
value to reference your new subclass.(Optional) Customize the results list output to display search result data related to your custom inputs. See Customizing the Results List Output.
Assemble the ATG Merchandising application and include your module in the modules list. See Assembling and Deploying an ATG Merchandising Application.
Deploy and start ATG Merchandising.
Verify that your new search test inputs work as expected.
Sample Search Testing Form Handler Subclass
Use the following sample code as a starting point for creating a subclass of the atg.search.web.assetmanager.CommerceSearchTestingFormHandler
class:
public void preSearch( DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse ) throws ServletException, IOException { QueryFormHandler queryFormHandler = getQueryFormHandler(); QueryRequest request = (QueryRequest)queryFormHandler.getSearchRequest(); String myControlValue = getAdvancedParameters().get( "myControl" ); /* logic to set something in request based on myControlValue */ super.preSearch( pRequest, pResponse ); }
Sample Advanced Inputs JSP
The advancedInputs.jsp
file contains the following sample code as a starting point for writing the JSP for your custom inputs:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <%@ taglib prefix="dspel" uri="http://www.atg.com/taglibs/daf/dspjspELTaglib1_0"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %> <%@ taglib prefix="assetui-search" uri="http://www.atg.com/taglibs/assetui search" %> <%@ taglib prefix="web-ui" uri="http://www.atg.com/taglibs/web-ui" %> <%-- dspel:page> <c:set var="formHandlerPath" value="${requestScope.formHandlerPath}"/> <c:set var="formHandler" value="${requestScope.formHandler}"/> <dt>My Control:</dt> <dd> <dspel:input id="myControl" type="text" bean="${formHandlerPath}.advancedParameters.myControl" /> </dd> </dspel:page--%>