+1
On Thu, Mar 19, 2009 at 5:55 AM, Bob Schellink <[email protected]> wrote:
> Its been suggested before to promote getFirstRow and getLastRow as public
> methods. Any reasons we should not do this for 2.1.0?
>
> This change makes it easier to enable paging of large datasets. Currently a
> Table's rowList must contain entries (even if its just a placeholder object)
> at every index in the list.
>
> By having the two methods as public an adapter or proxy could be used as
> the Table's rowList and it only need to be populated with the entries that
> should be displayed. So if the pageSize is 10, the rowList only needs 10
> entries, for example:
>
>
> public class TableModel extends ArrayList {
> private Table table;
> private int numOfRows;
>
> public TableModel(Table table, int numOfRows) {
> this.table = table;
> this.numOfRows = numOfRows;
> }
>
> public Object get(final int index) {
> // Convert expected index to real index
> int realIndex = index - table.getFirstRow();
> return super.get(realIndex);
> }
>
> public int size() {
> // Return numOfRows e.g. 100, even if only 10 entries exist
> return numOfRows;
> }
> }
>
> TableModel example usage:
>
> public void onRender() {
> TableModel model = new TableModel(table, getCustomerCount());
>
> table.setRowList(rows);
>
> List customers = getCustomers(table.getFirstRow(), table.getLastRow(),
> table.getPageSize());
>
> model.addAll(customers);
> }
>
> regards
>
> bob
>