📄 columnstag.java
字号:
package org.extremecomponents.table.tag;import java.util.Iterator;import java.util.List;import javax.servlet.jsp.JspException;import javax.servlet.jsp.tagext.TagSupport;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.AutoGenerateColumns;import org.extremecomponents.table.core.BaseModel;import org.extremecomponents.util.ExceptionUtils;/** * @jsp.tag name="columns" display-name="ColumnsTag" body-content="JSP" * description="Auto generate the columns." * * @author Jeff Johnston */public class ColumnsTag extends TagSupport { private static Log logger = LogFactory.getLog(ColumnsTag.class); private String autoGenerateColumns; /** * @jsp.attribute description="The fully qualified class name to add the * columns." required="true" rtexprvalue="true" */ public String getAutoGenerateColumns() { return TagUtils.evaluateExpressionAsString("autoGenerateColumns", autoGenerateColumns, this, pageContext); } public void setAutoGenerateColumns(String autoGenerateColumns) { this.autoGenerateColumns = autoGenerateColumns; } public int doEndTag() throws JspException { try { TableTag tableTag = (TableTag) findAncestorWithClass(this, TableTag.class); BaseModel model = tableTag.getModel(); if (model.getAutoGenerateColumns() == null) { Class classDefinition = Class.forName(autoGenerateColumns); model.setAutoGenerateColumns((AutoGenerateColumns) classDefinition.newInstance()); } if (!TagUtils.isIteratingBody(this)) { model.getAutoGenerateColumns().addColumns(model); } else { setColumnValues(tableTag); } return EVAL_PAGE; } catch (Exception e) { logger.error(ExceptionUtils.formatStackTrace(e)); throw new JspException("ColumnsTag.doEndTag() Problem: " + ExceptionUtils.formatStackTrace(e)); } } private void setColumnValues(TableTag tableTag) throws Exception { BaseModel model = tableTag.getModel(); List columns = model.getColumnHandler().getColumns(); Object bean = model.getCurrentCollectionBean(); Iterator iter = columns.iterator(); while (iter.hasNext()) { Column column = (Column) iter.next(); if ("true".equals(column.getAttribute(Column.IS_AUTO_GENERATE_COLUMN))) { String property = column.getProperty(); Object propertyValue = PropertyUtils.getProperty(bean, property); TagUtils.getModel(this).getViewHandler().addColumnValue(property, propertyValue, propertyValue); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -