⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tablehandler.java

📁 分页查询控件 分页查询控件
💻 JAVA
字号:
/* * Copyright 2004 original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *    http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.extremecomponents.table.handler;import java.util.ArrayList;import java.util.Collection;import java.util.List;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.extremecomponents.base.BaseModel;import org.extremecomponents.table.bean.Table;/** * The first pass over the table just loads up the column properties. The * properties will be loaded up and held here. *  * @author Jeff Johnston */public class TableHandler {    private static Log logger = LogFactory.getLog(TableHandler.class);    private BaseModel model;    private Table table;    private Object collectionOfBeans;    private Object currentCollectionBean;    /**     * The current page that will be displayed.     */    private int page;    /**     * The first row that will be displayed.     */    private int rowStart;    /**     * The last row that will be displayed.     */    private int rowEnd;    /**     * The totals rows that are in the Collection, not the rows just being     * displayed.     */    private int totalRows;    public TableHandler(BaseModel model) {        this.model = model;    }    public Table getTable() {        return table;    }    public void addTable(Table table) {        this.table = table;    }    /**     * @deprecated use the prefixWithCollection() attribute instead     */    public String getTableKey() {        return table.getCollection() + "_";    }    /**     * The unique name for this table.     */    public String prefixWithCollection() {        return table.getCollection() + "_";    }    public List getCollectionOfBeans() {        return (List) collectionOfBeans;    }    public void setCollectionOfBeans(Collection collectionOfBeans)            throws Exception {        this.collectionOfBeans = collectionOfBeans;        if (collectionOfBeans == null) {            String message = "The collection sent into the eXtremeTable is NULL.";            logger.error(message);            throw new Exception(message);        }    }    public Object getCurrentCollectionBean() {        return currentCollectionBean;    }    public void setCurrentCollectionBean(Object currentCollectionBean) {        this.currentCollectionBean = currentCollectionBean;    }    public int getPage() {        return page;    }    public int getRowStart() {        return rowStart;    }    public int getRowEnd() {        return rowEnd;    }    public int getTotalRows() {        return totalRows;    }    public void setTotalRows(int totalRows) {        this.totalRows = totalRows;    }    /**     * Find out where we should start and end to get the relevant section of the     * table.     */    public void setTableSections(int totalRows) {        if (this.totalRows == 0) {            this.totalRows = totalRows;        }        boolean invokeExport = model.getExportHandler().invokeExport();        if (invokeExport) {            page = 1;            rowStart = 1;            rowEnd = totalRows;            return;        }        page = model.getPaginationHandler().getPage();        int rowsDisplayed = Integer.parseInt(model.getTableHandler().getTable().getRowsDisplayed());        if (rowsDisplayed == 0) {            rowsDisplayed = totalRows;            page = 1;        }        if (rowStart == 0) {            rowStart = (page - 1) * rowsDisplayed;        }        if (rowEnd == 0) {            rowEnd = rowStart + rowsDisplayed;        }        if (rowEnd > this.totalRows) // make sure do not go over        {            rowEnd = this.totalRows;        }    }    /**     * Grab the relevant section of the table.     */    public Collection splitIntoTableSectionRows(Collection rows) {        boolean invokeExport = model.getExportHandler().invokeExport();        if (invokeExport) {            return rows;        }        Collection results = null;        if (getRowStart() >= rows.size()) { // obviously doing something custom            results = rows;        } else {            results = new ArrayList();            for (int i = getRowStart(); i < getRowEnd(); i++) {                Object obj = (Object) ((List) rows).get(i);                results.add(obj);            }        }        return results;    }    public boolean showPagination() {        if (!table.showPagination()) {            return false;        }        return !"0".equals(table.getInitialRowsDisplayed());    }    public void destroy() {        table = null;        collectionOfBeans = null;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -