The example above creates links for facet selection values. When an user clicks a link, the selection is added to the facet trail and a new search request is issued.

Your pages should also include links for removing facet selections. For example, if a customer chooses a “$100 to $200” selection range for the price facet, only items in that price range are displayed. To display all items regardless of price, the customer can click a link that removes this facet selection.

The following example creates a “remove” link for each facet selection. When a user clicks one of these links, the JSP removes the facet and selection value from the facet trail, along with any dependent facet selections. It also retrieves, updates, and resubmits the current search request.

<!-- use CommerceFacetTrailDroplet to transform the  -->
<!-- facet trail string into a FacetTrail object     -->
<dsp:droplet name="CommerceFacetTrailDroplet">

  <!-- expose the facet values as a jstl variable -->
  <dsp:getvalueof param="facetTrail.facetValues" var="facetValues"/>

  <dsp:oparam name="output">

  <c:forEach items="${facetValues}" var="currentFacetValue">
  <!-- Output the facet name and selection value separated by a colon; -->
  <!-- skip over the facet value containing the search question text   -->
  <c:set var="srchFacetLabel" value="SRCH"/>
  <c:if test="${ != srchFacetLabel}">
  <c:out value="${currentFacetValue.facet.label}:"/>
  <c:out value="${currentFacetValue.value}"/>

    <!-- create a remove link for each facet value; use the       -->
    <!-- CommerceFacetTrailDroplet to construct a new facet trail -->
    <dsp:droplet name="CommerceFacetTrailDroplet">
      <dsp:setvalue param="trail" value="${trailString}"/>
      <dsp:setvalue param="removeFacet" value="${currentFacetValue}"/>

      <!-- expose the facetTrail string as a jstl variable -->
      <dsp:getvalueof param="facetTrail" var="facetTrail"/>

      <dsp:oparam name="output">

        <!-- create a link back to this page that submits a     -->
        <!-- search request using the updated facet trail       -->
        <dsp:a href="simpleFacet.jsp">
          <dsp:property bean="QueryFormHandler.searchRequest.requestChainToken"
              name="qfh_rct" priority="30"/>
          <dsp:property bean="QueryFormHandler.searchRequest.saveRequest"
              value="true" name="fh_sr" priority="30"/>
          <dsp:property bean="QueryFormHandler.searchRequest.facetSearchRequest"
              value="true" name="qfh_fsr" priority="31"/>
          <dsp:property bean="FacetSearchTools.facetTrail"
              value="${facetTrail.trailString}" name="qfh_ft" priority="27"/>
          <dsp:param name="trail" param="facetTrail.trailString"/>
          <dsp:property bean="" value="submit"
loading table of contents...