You can use this simple dataTable backing bean to help. For more complicated options, you can look at the wiki [1].

**************
* Java Class *
**************

public class DataTableBacking {
        
        private final static int DEFAULT_ROWS = 5;
        public final static int NO_ROW_SELECTED = -1;
        
        private List records;
        private int selectedRowIndex;
        private int rowIndex;
        private int rowsPerPage = DEFAULT_ROWS;
        
        public TableData() {
                records = new ArrayList();
        }

        public TableData(List records){
                setRecords(records);
        }

        public List getRecords() {
                return this.records;
        }

        public void setRecords(List records) {
                setRecords(records, DEFAULT_ROWS);
        }
        
        public void setRecords(List records, int rowsPerPage) {
                this.records = records;
                this.rowsPerPage = rowsPerPage;
        }

        public void setRowsPerPage(int rowsPerPage) {
                this.rowsPerPage = rowsPerPage;
        }

        public int getRowsPerPage() {
                return rowsPerPage;
        }
                
        public int getSelectedRowIndex() {
                return selectedRowIndex;
        }

        public void setSelectedRowIndex(int selectedRowIndex) {
                this.selectedRowIndex = selectedRowIndex;
                this.setRowIndex(selectedRowIndex);
        }

        public int getRowIndex() {
                return rowIndex;
        }

        public void setRowIndex(int rowIndex) {
                this.rowIndex = roundDownRowIndex(rowIndex);
        }

        private int roundDownRowIndex(int rowIndex) {
                int page = rowIndex / rowsPerPage;
                int roundedIndex = page * rowsPerPage;
                return roundedIndex;
        }
}

*************
* DataTable *
*************

<t:dataTable id="TheDataTable"
        styleClass="tableBorder"
        headerClass="tableHeader"
        rowClasses="oddRow,evenRow"
rowStyleClass="#{dataTableBacking.selectedRowIndex == rowIndex ? 'highlightRow' : null}"
        columnClasses="standardTable_Column"
        value="#{dataTableBacking.records}"
        var="data"
        preserveDataModel="false"
        rows="#{dataTableBacking.rowsPerPage}"
        rowIndexVar="rowIndex"
        first="#{dataTableBacking.rowIndex}"
        >


More info:
[1] http://wiki.apache.org/myfaces/WorkingWithLargeTables

Regards,

Jeff Bischoff
Kenneth L Kurz & Associates, Inc.

Titi Wangsa wrote:
ok i solved it
using h:commandbutton
erm
new question

say i have 130 items in a List
and i use t:dataTable to display them
and i use a t:dataScroller to scroll through the data

say a page holds 20 items
if i drill down, to say, record number 23 on page number 2,
the details for that record gets displayed..
no problem

when i click the "back to list" button,
the list is displayed, no problem..
but.. its displayed at the 1st page displaying records 1 to 20

how do i get it to display records 21-40 (the records it displayed
before it displayed the record details).
i've managed to use HtmlDataTable.getFirst() to get first item on the page
but, i have no idea where to put the HtmlDataTable.setFirst(int value) code.





Reply via email to