tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Tapestry Wiki] Update of "Tapestry5HibernateGridDatasource2" by JulienHenry
Date Wed, 26 Mar 2008 12:49:40 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.

The following page has been changed by JulienHenry:
http://wiki.apache.org/tapestry/Tapestry5HibernateGridDatasource2

The comment on the change is:
Tapestry API changed

------------------------------------------------------------------------------
      }
  
      @SuppressWarnings("unchecked")
-     public void prepare(int startIndex, int endIndex, PropertyModel sortModel, boolean ascending)
{
+     public void prepare(int startIndex, int endIndex, List<SortConstraint> sortConstraints)
{
          //query is much faster if we take only results we need. it can be up to 10x faster
even for a small table with 1000 records
          criteria.setFirstResult(startIndex);
          criteria.setMaxResults(endIndex-startIndex+1);
          this.startIndex = startIndex;
  
+         for (SortConstraint sortConstraint : sortConstraints) {
-         String sortColumnName = null;
-         if(sortModel != null){
-             sortColumnName = sortModel.getPropertyName();
+             String sortColumnName = sortConstraint.getPropertyModel().getPropertyName();
+             boolean ascending = (sortConstraint.getColumnSort()==ColumnSort.ASCENDING);
              Order order = ascending ? Order.asc(sortColumnName) : Order.desc(sortColumnName);
              criteria.addOrder(order);
+             if(_resources != null) _resources.triggerEvent("sortColumn", new Object[]{criteria,sortColumnName,
ascending, persistentClass},null);
          }
-         if(_resources != null) _resources.triggerEvent("sortColumn", new Object[]{criteria,sortColumnName,
ascending, persistentClass},null);
  
          data = criteria.list();
      }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Mime
View raw message