When a customer submits a text query through the QueryFormHandler, the search text is stored in the question property of the QueryRequest component, and returned (with possible modifications) in the question property of the QueryRequest.Response object. Submitting search text creates a new search request with an empty facet trail. When the customer makes a facet selection, it is added to the facet trail that is included in the subsequent search request.

The following JSP code implements the logic for building up the facet trail. If the facet trail is empty and the question property of the response object is not empty, this means that the user has entered search text as the most recent search request. In this case, the code sets the facet trail to SRCH:text plus whatever facet selection the customer makes.

If, however, there is already a non-empty facet trail or the question property of the response object is empty, this means that either the SRCH facet has already been added to trail, or there is no SRCH facet (because there is no search text). So in either of these cases only the facet selection the customer makes is added to the trail.

<dsp:droplet name="CommerceFacetTrailDroplet">
  <dsp:setvalue param="trail" value="${trailString}"/>

  <c:if test="${ empty trailString and ! empty queryResponse.question }">
    <dsp:setvalue param="addFacet"
      value="SRCH:${queryResponse.question}:${facetValueNode.facetValue}"/>
  </c:if>
  <c:if test="${ ! empty trailString or empty queryResponse.question }">
    <dsp:setvalue param="addFacet" value="${facetValueNode.facetValue}"/>
  </c:if>

. . .
 
loading table of contents...