Paged Query Returns

Back | Home | Next

Metacat allows results sets to be broken up into "pages" to aid in the loading of large result sets and to make the result sets more readable to users. This is facilitated by the addition of two variables to the parameter list. Pagesize indicates how many results should be returned for a given page. Pagestart indicates which page you are currently viewing. These parameters can be passed to Metacat when a query is submited.

When a paged query is performed, the resultset of that query contains four extra fields. Pagestart and pagesize are contained in the xml resultset along with nextpage and previouspage. This allows the xslt tranformation to include navigational links in the rendered resultset. Here's an example xml resultset.

    <resultset>
      <pagestart>1</pagestart>
      <pagesize>10</pagesize>
      <nextpage>2</nextpage>
      <previouspage>0</previouspage>
      <query>
      ...
      </query>
      <document>...</document>
      <document>...</document>
    </resultset>
  

In the case of the resultset, pagestart will always indicate the page you are currently viewing.

Here's an example of the rendered result.

The links to the previous and next pages look like this.

   <a href="metacat?action=query&operator=INTERSECT&enableediting=false&anyfield=actor&qformat=kepler&pagestart=0&pagesize=10">Previous Page</a>
   <a href="metacat?action=query&operator=INTERSECT&enableediting=false&anyfield=actor&qformat=kepler&pagestart=2&pagesize=10">Next Page</a>
  

The important bits of these links are the incremented pagestart parameters. The rendered page is on page 1 so the previous page is 0 and the next page is 2. By sequencing through the pages, the user can see the entire resultset.

The Kepler skin in lib/style/skins/kepler is a good example of how to render the resultset with paged query returns. The XSLT uses the four extra fields in the resultset to render the next and previous links. This could also be used within a non-web application.


Back | Home | Next