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:
siteIds—Only items that belong to the specified sites are returned.siteScope—Specifies the site scope to use when searching for items. Possible values include:current—Returns matching repository items from the current site only. This is the default.all—Returns all matching repository items and does not filter based on site context.any—Returns matching repository items that belong to any site.none—Returns matching repository items that don’t have any site affiliations.shareable_type_ID—Returns matching repository items that belong to any sites that are in a sharing group with the current site, as defined by theShareableTypecomponent ID. For example, you can return items that belong to sites that share a shopping cart with the current site.
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>
