Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have to use external pagination feature. First, specify in html tag that you're using external pagination. And create an object implements <em>org.displaytag.pagination.PaginatedList</em>. Finally, you have to implement the DAO which makes actually query for 15 rows only and returns PaginatedList.</p> <p>1) Your jsp will look like this</p> <pre><code>&lt;display:table name="command" sort="external" partialList="true" size="${command.fullListSize}" pagesize="${command.objectsPerPage}"&gt; &lt;display:column property="name" title="name"/&gt; ... &lt;/display:table&gt; </code></pre> <p>Note that it specified the sort is external.</p> <p>2) org.displaytag.pagination.PaginatedList implementation.</p> <pre><code>public class PaginatedListImpl&lt;T&gt; implements PaginatedList{ private int fullListSize; private int objectsPerPage; private int pageNumber; private String searchId; private String sortCriterion; private SortOrderEnum sortDirection; private List&lt;T&gt; list; //getters and setters ... } </code></pre> <p>3) DAO Implementation sample using hibernate. You can do it with JDBC or anything but make sure you're making the right query to get 15 rows in proper order and return PaginatedListImpl object.</p> <pre><code>@SuppressWarnings("unchecked") public PaginatedListImpl&lt;T&gt; getPaginatedList(PaginatedListImpl paginatedList) { int pageNum = paginatedList.getPageNumber(); final int objectsPerPage = paginatedList.getObjectsPerPage(); final int firstResult = objectsPerPage * pageNum; String sortOrderCriterion = pagiantedList.getSortOrderCriterion(); String sortOrder = paginatedList.getSortOrder String className = type.getName().substring(type.getName().lastIndexOf(".") + 1); final StringBuilder fromClause = new StringBuilder("from " + className + " " + alias); String orderByClause = new StringBuilder(" order by ").append(sortCriterion).append(" ").append(sortDirection); final String hql = new StringBuilder().append(fromClause).append(orderClause).toString(); List&lt;T&gt; resultList = getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { return session.createQuery(hql) .setFirstResult(firstResult) .setMaxResults(objectsPerPage) .list(); } }); Long count = (Long)getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { return session.createQuery("select count(*) " + fromClause).uniqueResult(); } }); paginatedList.setFullListSize(count.intValue()); paginatedList.setList(resultList); paginatedList.setPageNumber(pageNum+1); paginatedList.setObjectsPerPage(objectsPerPage); return paginatedList; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload