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

📄 generatecolumns.java

📁 exTreme taglib的使用
💻 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.tag;import java.util.Collection;import java.util.Iterator;import java.util.List;import org.apache.commons.beanutils.PropertyUtils;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.extremecomponents.table.bean.Column;import org.extremecomponents.table.core.BaseModel;import org.extremecomponents.util.ExtremeUtils;/** * Helper methods for the tag classes. Trying to keep the logic out of the tags * so can move to the JSP 2.0 container easier. *  * @author $author$ */public final class GenerateColumns {    private static Log logger = LogFactory.getLog(TableTag.class);    private GenerateColumns() {    }    /**     * If no columns are defined then set the columns automatically. Note: This     * is just for testing...the filtering or headers will not work.     */    public static void autoSetColumns(TableTag tableTag, Collection rows)            throws Exception {        logger.info("no columns defined so set them automatically");        BaseModel model = tableTag.getModel();        // set column meta data        for (Iterator iter = rows.iterator(); iter.hasNext();) {            Object bean = iter.next();            List properties = ExtremeUtils.beanProperties(bean);            autoAddColumns(model, bean, properties);            break;        }        // set column values        for (Iterator iter = rows.iterator(); iter.hasNext();) {            Object bean = iter.next();            List properties = ExtremeUtils.beanProperties(bean);            model.getRowHandler().increaseRowCount();            autoAddColumns(model, bean, properties);        }    }    public static void autoAddColumns(BaseModel model, Object bean, List properties)            throws Exception {        for (Iterator iter = properties.iterator(); iter.hasNext();) {            String property = (String) iter.next();            if (property.equals("class")) {                continue;            }            Object value = PropertyUtils.getProperty(bean, property);            if (model.getRowHandler().getRow().getRowCount() > 0) {                model.getViewHandler().addColumnValue(property, value, value);            } else {                Column column = new Column();                column.addAttribute(Column.PROPERTY, property);                column.addAttribute(Column.CELL, ColumnTagUtils.getCell(model, null));                model.getColumnHandler().addColumn(column);            }        }    }}

⌨️ 快捷键说明

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