Class Name

atg.commerce.search.refinement.CommerceFacetTrailDroplet

Component

/atg/commerce/search/refinement/CommerceFacetTrailDroplet

This servlet bean takes as input a String representing a facet trail, plus additional input parameters specifying modifications to the facet trail. It outputs the modified facet trail as a FacetTrail object, which can then be rendered on the page or passed to the FacetSearchDroplet.

The input parameters can be set explicitly or they can be set by the page’s URL query parameters. For example, when a customer clicks a link for a selection value, the query parameter corresponding to the servlet bean’s addFacet parameter can be set to this selection value. When the new page is displayed, the chosen value will appear at the end of the facet trail. Similarly, another link could be used to remove a selection value or range from the facet trail.

Input Parameters

trail
String that represents the current facet trail. This parameter’s value is typically specified through a query parameter in the URL for the page. The name of the query parameter that sets the value of this input parameter is configured through the trailParameterName property.

refineConfig
The refineConfig repository item to use for querying ATG Search. If this value is not specified, the refinement configuration will be chosen automatically.

addFacet
String that represents an entry (consisting of a facet and an associated selection value or range) to add to the facet trail. This parameter’s value is typically specified through a query parameter in the URL for the page. The name of the query parameter that sets the value of this input parameter is configured through the addFacetParameterName property.

removeFacet
String that represents an entry to remove from the trail. This parameter’s value is typically specified through a query parameter in the URL for the page. The name of the query parameter that sets the value of this input parameter is configured through the removeFacetParameterName property.

removeAllFacets
If this parameter is set to true, the facet trail is cleared. This parameter’s value is typically specified through a query parameter in the URL for the page. The name of the query parameter that sets the value of this input parameter is configured through the removeAllFacetsParameterName property.

removeFacetType
The item ID of a refinement element repository item (i.e., a facet); specifies that all facet values or ranges for this facet should be removed from the facet trail. This parameter’s value is typically specified through a query parameter in the URL for the page. The name of the query parameter that sets the value of this input parameter is configured through the removeFacetTypeParameterName property.

Output Parameters

facetTrail
The FacetTrail object generated from the input or query parameters.

errorMessage
The message generated if an error occurs when creating the FacetTrail object.

Open Parameters

output
This open parameter is rendered if no errors occur when creating the FacetTrail object.

error
This open parameter is rendered if any errors occur when creating the FacetTrail object.

Example

This example shows a page that renders the current facet trail, and provides links for removing each individual entry in the trail.

Note: This is a simplified example for illustrative purposes only. For a more realistic example, there are several sample JSPs in <ATG2007.3>/DAF/Search/Query/SearchTest/web-apps/search.war that use the faceted navigation servlet beans. You may find these pages helpful as starting points for writing your own JSPs.

<%@ taglib uri="dsp" prefix="dsp" %>

<dsp:page>

  <%-- Import components used in this page --%>
  <dsp:importbean
    bean="/atg/commerce/search/refinement/CommerceFacetTrailDroplet"/>
  <dsp:importbean bean="/atg/dynamo/droplet/ForEach"/>
  <dsp:importbean bean="/atg/dynamo/droplet/Switch"/>
  <dsp:importbean bean="/atg/dynamo/droplet/IsNull"/>
  <dsp:importbean bean="/atg/dynamo/droplet/IsEmpty"/>

  <%-- Convert the trail parameter to a bean --%>
  <dsp:droplet name="CommerceFacetTrailDroplet">

    <dsp:setvalue param="facetValues" paramvalue="facetTrail.facetValues"/>

    <dsp:oparam name="error">
      Error reported by Facet Trail droplet:</b>
      <dsp:valueof param="errorMessage"/>
    </dsp:oparam>

    <%-- Render the facet trail on the page --%>
    <dsp:oparam name="output">
      <dsp:droplet name="ForEach">
        <dsp:param name="array" param="facetValues"/>

        <dsp:setvalue param="currentFacetValue" paramvalue="element"/>

        <dsp:oparam name="empty">
          No facet values selected<br/>
        </dsp:oparam>

        <dsp:oparam name="outputStart">
          Current trail:<br/>
        </dsp:oparam>

        <dsp:oparam name="output">

          <%-- Put a separator between each selection value --%>
          <dsp:droplet name="Switch">
            <dsp:param name="value" param="count"/>
            <dsp:oparam name="1"/>
            <dsp:oparam name="default">
              &gt;
            </dsp:oparam>
          </dsp:droplet>

          <%-- Output the facet name and selection value separated by a colon --%>
          <dsp:droplet name="IsNull">
            <dspel:param name="value" param="currentFacetValue.facet.label"/>
            <dsp:oparam name="true">
              <dsp:valueof param="currentFacetValue.facet.id"/>:
            </dsp:oparam>
            <dsp:oparam name="false">
              <dsp:valueof param="currentFacetValue.facet.label"/>:
            </dsp:oparam>
          </dsp:droplet>

          <dsp:valueof param="currentFacetValue.value"/>

          <%--
            Add a remove option. Clicking this will take user to a page
            whose URL is specified in a variable named 'removeFacetUrl'.
          --%>
          <dsp:getvalueof id="removeFacetUrl" idtype="String"
             bean="/OriginatingRequest.requestURI">
            <dsp:a href="<%=removeFacetUrl%>">
              <dsp:param name="trail" param="facetTrail"/>
              <dsp:param name="rem" param="currentFacetValue"/>
              <img src="../images/removeFacet.gif"/>
            </dsp:a>
          </dsp:getvalueof>

        </dsp:oparam>  <%-- output oparam --%>
      </dsp:droplet> <%-- ForEach --%>

    </dsp:oparam> <%-- output oparam --%>
  </dsp:droplet> <%-- CommerceFacetTrailDroplet --%>

</dsp:page>
 
loading table of contents...