Sunday, January 15, 2012

ATG Type of Paging

ATG Search supports two types of paging, normal paging and fast paging. The key differences between them relate to the information you get back from the search engine about the number of pages of results, and the navigation you can build into your pages:

Normal paging is the default. In this mode, the search engine returns (in the form handler’s pagesAvailable property), the total number of pages of results. You can create links that enable the customer to go directly to any page.

Fast paging is specified by setting the fastPaging property of the search request to true. In this mode, the search engine does not return information about the total number of pages of results; pagesAvailable is set to the highest-numbered page that has been rendered so far. You can enable customers to go to the next page or to any page previously rendered.

For a single-partition index, normal paging is always enabled (the fastPaging property is ignored). For a multi-partition index, you can choose between normal paging and fast paging, but fast paging is recommended. Fast paging is much less resource-intensive than normal paging. On multi-partition indexes, normal paging can be very memory- and CPU-intensive, because results from the partitions must be merged.

Example of Normal Paging

The following example renders a list of the page numbers of all pages of results. Each page number is a link to the corresponding results page, except for the current page number, which is displayed without a link. For example, if pagesAvailable is 43 and the current page is page 10, this code will render the integers from 1 to 43, and all of these except 10 will be links. If the user clicks 22, for example, a request to display page 22 will be issued.

<dsp:input type="hidden" bean="QueryFormHandler.searchRequest.requestChainToken"
    name="requestChainToken"/>
<dsp:input type="hidden" bean="QueryFormHandler.goToPage" name="goToPage"
    beanvalue="Constants.null" converter="nullable"/>


<dsp:droplet name="For">
  <dsp:param bean="QueryFormHandler.pagesAvailable" name="howMany"/>
  <dsp:oparam name="output">
    <dsp:droplet name="Switch">
      <dsp:param bean="QueryFormHandler.goToPage" name="value"/>
      <dsp:getvalueof id="pageValue" param="count" idtype="java.lang.Integer">
        <dsp:oparam name="<%=pageValue.toString()%>">
          <%--Switch value matched the current page, so just render the page num,
          not a link--%>
          <dsp:valueof param="count"/>
        </dsp:oparam>
      </dsp:getvalueof>
      <dsp:oparam name="default">
        <%--the other pages are links--%>
        <dsp:a href="queryExampleNormalSave.jsp#Paging">
          <dsp:valueof param="count"/>
          <dsp:property bean="QueryFormHandler.goToPage" paramvalue="count"
             name="fh_gtp" priority="29"/>
          <dsp:property bean="QueryFormHandler.searchRequest.saveRequest"
             value="true" name="fh_sr" priority="30"/>
          <dsp:property bean="QueryFormHandler.searchRequest.facetSearchRequest"
             value="true" name="fh_fsr" priority="30"/>
          <dsp:property bean="QueryFormHandler.searchRequest.requestChainToken"
             value="${formHandler.searchResponse.requestChainToken}" name="fh_rct"
             priority="30"/>
        </dsp:a>
      </dsp:oparam>
    </dsp:droplet>
  </dsp:oparam>
</dsp:droplet>


Example of Fast Paging

The following example renders a list of the page numbers of the results pages that have been rendered so far. Each page number is a link to the corresponding results page, except for the current page number, which is displayed without a link. In addition, the example renders the word “next” as a link to the page following the current one.

<dsp:input type="hidden" bean="QueryFormHandler.searchRequest.requestChainToken"
    name="requestChainToken"/>
<dsp:input type="hidden" bean="QueryFormHandler.goToPage" name="goToPage"
    beanvalue="Constants.null" converter="nullable"/>


<dsp:droplet name="Switch">
  <dsp:param bean="QueryFormHandler.pagesAvailable" name="value"/>
  <dsp:oparam name="1">
    <%--one page, but in the fast case we need to show a '1' and provide a Next
     link b/c fast always starts with only one and we don't know if there'll be
     more--%>
    <c:if test="${multi}">
       1 <dsp:a href="queryExampleFastSave.jsp#Paging">
          next
         <dsp:property bean="QueryFormHandler.goToPage" value="2" name="fh_gtp"
          priority="29"/>
         <dsp:property bean="QueryFormHandler.searchRequest.saveRequest"
                         value="true" name="fh_sr" priority="30"/>
         <dsp:property bean="QueryFormHandler.searchRequest.requestChainToken"
                         value="${formHandler.searchResponse.requestChainToken}"
                         name="fh_rct" priority="30"/>
       </dsp:a>
    </c:if>
    </dsp:oparam>
    <dsp:oparam name="default">
    <%--the remaining pages. render links for page nums other than the current--%>
      <dsp:droplet name="For">
        <dsp:param bean="QueryFormHandler.pagesAvailable" name="howMany"/>
        <dsp:oparam name="output">
          <dsp:droplet name="Switch">
            <dsp:param bean="QueryFormHandler.goToPage" name="value"/>
            <dsp:getvalueof id="pageValue" param="count"
               idtype="java.lang.Integer">
              <dsp:oparam name="<%=pageValue.toString()%>">
                <%--Switch value matched the current page, so just render the
                  page num, not a link--%>
                <dsp:valueof param="count"/>
              </dsp:oparam>
            </dsp:getvalueof>
            <dsp:oparam name="default">
              <%--the other pages are links--%>
               <dsp:a href="queryExampleFastSave.jsp#Paging">
                 <dsp:valueof param="count"/>
                 <dsp:property bean="QueryFormHandler.goToPage" paramvalue="count"
                  name="fh_gtp" priority="29"/>
                 <dsp:property bean="QueryFormHandler.searchRequest.saveRequest"
                                  value="true" name="fh_sr" priority="30"/>
                 <dsp:property
                   bean="QueryFormHandler.searchRequest.requestChainToken"
                   value="${formHandler.searchResponse.requestChainToken}"
                   name="fh_rct" priority="30"/>
               </dsp:a>
            </dsp:oparam>
          </dsp:droplet>
        </dsp:oparam>
      </dsp:droplet>
      <%--Need to show the 'next' link for Fast--%>
      <c:if test="${multi}">
         <dsp:a href="queryExampleFastSave.jsp#Paging">
           &nbsp; next
           <dsp:property bean="QueryFormHandler.goToPage"
            value="${formHandler.goToPage + 1}" name="fh_gtp" priority="29"/>
           <dsp:property bean="QueryFormHandler.searchRequest.saveRequest"
                            value="true" name="fh_sr" priority="30"/>
           <dsp:property bean="QueryFormHandler.searchRequest.requestChainToken"
            value="${formHandler.searchResponse.requestChainToken}" name="fh_rct"
            priority="30"/>
         </dsp:a>
      </c:if>
    </dsp:oparam>
</dsp:droplet>

No comments:

Popular Posts