A gadget is an individual piece of functionality encapsulated in a JSP file so it can easily be included in multiple pages or moved to different locations on a page. For example, the dropdown for selecting sorting options on a category page executes logic implemented by the store.war/global/gadgets/sortDisplay.jsp file.

The use of gadgets makes it possible to build pages from reusable elements. For example, consider the store.war/navigation/gadgets/search.jsp gadget, which creates the search dialog box found on most pages:

<dsp:page>
  <dsp:importbean bean="/atg/store/StoreConfiguration" var="storeConfiguration" />

  <div id="atg_store_search">
    <c:choose>
      <%-- If ATG Search is installed use ATG Search --%>
      <c:when test="${storeConfiguration.atgSearchInstalled == 'true'}">
        <dsp:include page="/atgsearch/gadgets/atgSearch.jsp" />
      </c:when>
      <%-- If ATG Search is not installed use Repository Search --%>
      <c:otherwise>
        <dsp:include page="/search/gadgets/simpleSearch.jsp" />
      </c:otherwise>
    </c:choose>
  </div>
</dsp:page>

This gadget determines whether Search is installed and, if it is, invokes another gadget that creates a search form for issuing queries to Search. If Search is not installed, the store.war/navigation/gadgets/search.jsp gadget instead invokes a gadget that creates a form for using ATG’s basic search facility.