To implement search in your pages, ensure that your JSP includes the search servlet bean. This example uses CatalogSearch, but you can use any of the other servlet beans for more specific searches.

<IMPORTBEAN BEAN="/atg/commerce/catalog/CatalogSearch">

SearchFormHandler executes its search query when the handleSearch method is called. Typically, you associate the form handler’s search property with a submit button, as in this example:

<dsp:input bean="/myCatalog/SearchForm.search" value="Go" type="submit"/>

You can limit searches to a specific catalog or set of catalogs. The CatalogSearchFormHandler and FilteringSearchFormHandler both include catalogs and queryByCatalog properties. The catalogs property contains an array of catalog IDs. If this property is populated, then only items that have membership in at least one of the specified catalogs are returned. If the catalogs property is null, but the queryByCatalog property is set to true, the query is limited to the user’s current catalog. If catalogs is null and queryByCatalog is false, the query searches all catalogs.

If you are using the multisite feature, you can also limit searches to a specific site or sites, using the following parameters:

The following example shows a product search form that uses the siteIds property to filter search results by site:

<dsp:importbean bean="/atg/dynamo/droplet/ForEach" />
<dsp:importbean bean="/atg/multisite/Site"/>
<dsp:importbean bean="/atg/commerce/catalog/ProductSearch"/>
<dsp:getvalueof id="contextroot" idtype="java.lang.String" bean="/Originating
Request.contextPath"/>

<dsp:form action="${contextroot}/search/searchResults.jsp" method="post" id=
"simpleSearch" formid="simplesearchform">

    <%-- Search input control --%>
    <dsp:input bean="ProductSearch.searchInput" type="text" value="" />

    <%-- Get the list of sites that share a shopping cart with the
    current site. --%>
    <dsp:droplet name="SharingSitesDroplet">
      <dsp:param name="shareableTypeId" value="atg.ShoppingCart"/>
      <dsp:param name="excludeInputSite" value="true"/>

      <%-- Loop through the sites that share a shopping cart and render labels
      and checkboxes for them. --%>
      <dsp:oparam name="output">
        <dsp:droplet name="ForEach">
          <dsp:param name="array" param="sites"/>
          <dsp:setvalue param="site" paramvalue="element"/>

            <%-- Display a checkbox and name for the current site first. --%>
            <dsp:oparam name="outputStart">
              <dsp:input bean="ProductSearch.siteIds" type="checkbox"
                         beanvalue="Site.id" checked="true" id="currentStore"/>
              <label for="currentStore">
                <dsp:valueof bean="Site.name"/>
              </label>
            </dsp:oparam>

<%-- Display the other sites that share shopping cart with the current
            site. --%>
            <dsp:oparam name="output">
                <dsp:input bean="ProductSearch.siteIds" type="checkbox"
                     paramvalue="site.id" id="otherStore" checked="false"/>
                <label for="otherStore">
                  <dsp:valueof param="site.name"/>
                </label>
            </dsp:oparam>
        </dsp:droplet>
      </dsp:oparam>

      <%-- If there are no shared sites, include the current site only and
      don't display checkboxes. --%>
      <dsp:oparam name="empty">
        <dsp:input bean="ProductSearch.siteIds" type="hidden"
                   beanvalue="Site.id"/>
      </dsp:oparam>
    </dsp:droplet>

    <%-- Display the search form's submit button. --%>
    <dsp:input bean="ProductSearch.search" type="submit"  value="Search"/>

</dsp:form>

Copyright © 1997, 2015 Oracle and/or its affiliates. All rights reserved. Legal Notices