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 links for sorting product listings on a category page execute logic implemented by the /global/gadgets/sortGadget.jsp file.

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

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

   <div id="atg_store_search">
    <dsp:getvalueof var="atgSearchInstalled"
         bean="StoreConfiguration.atgSearchInstalled" />
    <c:choose>
      <c:when test="${atgSearchInstalled == 'true'}">
        <dsp:include page="/atgsearch/gadgets/atgSearch.jsp" />
      </c:when>
      <c:otherwise>
        <dsp:include page="/search/gadgets/simpleSearch.jsp" />
      </c:otherwise>
    </c:choose>
  </div>

</dsp:page>

This gadget determines whether ATG Search is installed and, if it is, invokes another gadget that creates a search form for issuing queries to ATG Search. If ATG Search is not installed, the /navigation/gadgets/search.jsp gadget instead invokes a gadget that creates a form for performing database searches.

 
loading table of contents...