Home » tapestry-src-5.0.19 » org.apache.tapestry5.grid » [javadoc | source]

    1   // Copyright 2007, 2008 The Apache Software Foundation
    2   //
    3   // Licensed under the Apache License, Version 2.0 (the "License");
    4   // you may not use this file except in compliance with the License.
    5   // You may obtain a copy of the License at
    6   //
    7   //     http://www.apache.org/licenses/LICENSE-2.0
    8   //
    9   // Unless required by applicable law or agreed to in writing, software
   10   // distributed under the License is distributed on an "AS IS" BASIS,
   11   // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12   // See the License for the specific language governing permissions and
   13   // limitations under the License.
   14   
   15   package org.apache.tapestry5.grid;
   16   
   17   import java.util.List;
   18   
   19   /**
   20    * Defines how a {@link org.apache.tapestry5.corelib.components.Grid} component (and its sub-components) gain access to
   21    * the row data that is displayed on the page. In many cases, this is just a wrapper around a simple List, but the
   22    * abstractions exist to support access to a large data set that is accessible in sections.
   23    */
   24   public interface GridDataSource
   25   {
   26       /**
   27        * Returns the number of rows available in the data source.
   28        */
   29       int getAvailableRows();
   30   
   31       /**
   32        * Invoked to allow the source to prepare to present values. This gives the source a chance to pre-fetch data (when
   33        * appropriate) and informs the source of the desired sort order.  Sorting comes first, then extraction by range.
   34        *
   35        * @param startIndex      the starting index to be retrieved
   36        * @param endIndex        the ending index to be retrieved
   37        * @param sortConstraints identify how data is to be sorted
   38        */
   39       void prepare(int startIndex, int endIndex, List<SortConstraint> sortConstraints);
   40   
   41       /**
   42        * Returns the row value at the provided index. This method will be invoked in sequential order. In rare instances,
   43        * {@link #getAvailableRows()} may return a different number of rows than are actually available (i.e., the database
   44        * was changed between calls to {@link #getAvailableRows()} and the call to {@link #prepare(int, int,
   45        * java.util.List)}).  In that case, this method should return null for any out-of-range indexes.
   46        */
   47       Object getRowValue(int index);
   48   
   49       /**
   50        * Returns the type of value in the rows, or null if not known. This value is used to create a default {@link
   51        * org.apache.tapestry5.beaneditor.BeanModel} when no such model is explicitly provided.
   52        *
   53        * @return the row type, or null
   54        */
   55       Class getRowType();
   56   }

Home » tapestry-src-5.0.19 » org.apache.tapestry5.grid » [javadoc | source]