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

📄 tabletagutils.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.tag;import java.util.Locale;import javax.servlet.jsp.PageContext;import org.apache.commons.lang.StringUtils;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.extremecomponents.base.BaseModel;import org.extremecomponents.base.BaseProperties;import org.extremecomponents.base.BaseResourceBundle;import org.extremecomponents.table.bean.Table;import org.extremecomponents.table.core.ParameterRegistry;import org.extremecomponents.table.core.TableModelUtils;import org.extremecomponents.table.core.TableProperties;/** * Pull the complicated values for the TableTag. Because the default values * could be coming from the properties or resource bundle this class will * abstract that out. *  * @author Jeff Johnston */public class TableTagUtils {    private static Log logger = LogFactory.getLog(TableTagUtils.class);    public static String getId(String id, String collection) {        if (StringUtils.isEmpty(id)) {            return collection;        }        return id;    }    public static String getStyleClass(BaseModel model, String styleClass) {        if (StringUtils.isEmpty(styleClass)) {            return model.getProperties().getProperty(BaseProperties.STYLE_CLASS);        }        return styleClass;    }    public static String getHeaderClass(BaseModel model, String headerClass) {        if (StringUtils.isEmpty(headerClass)) {            return model.getProperties().getProperty(BaseProperties.HEADER_CLASS);        }        return headerClass;    }    public static String getBorder(BaseModel model, String border) {        if (StringUtils.isEmpty(border)) {            return model.getProperties().getProperty(BaseProperties.BORDER);        }        return border;    }    public static String getCellpadding(BaseModel model, String cellpadding) {        if (StringUtils.isEmpty(cellpadding)) {            return model.getProperties().getProperty(BaseProperties.CELLPADDING);        }        return cellpadding;    }    public static String getCellspacing(BaseModel model, String cellspacing) {        if (StringUtils.isEmpty(cellspacing)) {            return model.getProperties().getProperty(BaseProperties.CELLSPACING);        }        return cellspacing;    }    public static String getRowsDisplayed(PageContext pageContext, BaseModel model, String rowsDisplayed,            String showPagination, String collection) {        if (model.getExportHandler().invokeExport() || showPagination.equalsIgnoreCase("false")) {            return "0";        } else {            String paramRowsDisplayed = pageContext.getRequest().getParameter(                    collection + "_" + ParameterRegistry.ROWS_DISPLAYED);            if (StringUtils.isNotBlank(paramRowsDisplayed)) {                return paramRowsDisplayed;            }        }        if (StringUtils.isBlank(rowsDisplayed)) // default if still not set        {            return model.getProperties().getProperty(BaseProperties.ROWS_DISPLAYED);        }        return rowsDisplayed;    }    public static String getFilterable(BaseModel model, String filterable) {        if (StringUtils.isEmpty(filterable)) {            return model.getProperties().getProperty(BaseProperties.FILTERABLE);        }        return filterable;    }    public static String getShowPagination(BaseModel model, String showPagination) {        if (StringUtils.isEmpty(showPagination)) {            return model.getProperties().getProperty(BaseProperties.SHOW_PAGINATION);        }        return showPagination;    }    public static String getShowExports(BaseModel model, String showExports) {        if (StringUtils.isEmpty(showExports)) {            return model.getProperties().getProperty(BaseProperties.SHOW_EXPORTS);        }        return showExports;    }    public static String getShowStatusBar(BaseModel model, String showStatusBar) {        if (StringUtils.isEmpty(showStatusBar)) {            return model.getProperties().getProperty(BaseProperties.SHOW_STATUS_BAR);        }        return showStatusBar;    }    public static String getImagePath(BaseModel model, String imagePath) {        if (StringUtils.isBlank(imagePath)) {            String resourceValue = model.getResourceBundle().getResourceByPrefix(BaseResourceBundle.IMAGE_PATH);            if (resourceValue != null) {                return resourceValue;            }            return model.getProperties().getProperty(BaseResourceBundle.IMAGE_PATH);        }        return imagePath;    }    public static String getSortable(BaseModel model, String sortable) {        if (StringUtils.isEmpty(sortable)) {            return model.getProperties().getProperty(BaseProperties.SORTABLE);        }        return sortable;    }    public static String getTitle(BaseModel model, String title) {        if (TableModelUtils.isResourceBundleProperty(title)) {            String resourceValue = model.getResourceBundle().getResource(title);            if (resourceValue != null) {                return resourceValue;            }        }        return title;    }    public static String getWidth(BaseModel model, String width) {        if (StringUtils.isEmpty(width)) {            return model.getProperties().getProperty(BaseProperties.WIDTH);        }        return width;    }    public static String getAutoIncludeParameters(BaseModel model, String autoIncludeParameters) {        if (StringUtils.isEmpty(autoIncludeParameters)) {            return model.getProperties().getProperty(BaseProperties.AUTO_INCLUDE_PARAMETERS);        }        return autoIncludeParameters;    }    public static String getFilterRowsCallback(BaseModel model, String filterRowsCallback) {        if (StringUtils.isEmpty(filterRowsCallback)) {            return model.getProperties().getProperty(BaseProperties.FILTER_ROWS_CALLBACK);        }        return filterRowsCallback;    }    public static String getRetrieveRowsCallback(BaseModel model, String retrieveRowsCallback) {        if (StringUtils.isEmpty(retrieveRowsCallback)) {            return model.getProperties().getProperty(BaseProperties.RETRIEVE_ROWS_CALLBACK);        }        return retrieveRowsCallback;    }    public static String getSortRowsCallback(BaseModel model, String sortRowsCallback) {        if (StringUtils.isEmpty(sortRowsCallback)) {            return model.getProperties().getProperty(BaseProperties.SORT_ROWS_CALLBACK);        }        return sortRowsCallback;    }    public static String getView(BaseModel model, String view) {        if (StringUtils.isEmpty(view)) {            return model.getProperties().getProperty(BaseProperties.VIEW_HTML);        }        return view;    }    public static String getLocale(BaseModel model, String locale) {        if (StringUtils.isEmpty(locale)) {            return model.getProperties().getProperty(BaseProperties.LOCALE);        }        return locale;    }    public static Locale getLocaleObject(PageContext pageContext, String locale) {        if (StringUtils.isBlank(locale)) {            return pageContext.getRequest().getLocale();        }        Locale result = null;                String parts[] = StringUtils.split(locale, "_");        if (parts.length != 2) {            String message = "You specified an incorrect Locale. "                            + " It must be in the form 'language_country'"                           + " For example en_US or de_DE";            logger.error(message);        } else {            String language = parts[0];            String country = parts[1];            result = new Locale(language, country);        }        return result;    }    public static String getResourceBundleLocation(PageContext pageContext) {        String result = pageContext.getServletContext().getInitParameter(Table.RESOURCE_BUNDLE_LOCATION);        if (StringUtils.isNotBlank(result)) {            return result;        }        return null;    }    public static String getPropertiesLocation(PageContext pageContext) {        String result = pageContext.getServletContext().getInitParameter(Table.PROPERTIES_LOCATION);        if (StringUtils.isNotBlank(result)) {            return result;        }        return "/" + TableProperties.EXTREMECOMPONENTS_PROPERTIES;    }}

⌨️ 快捷键说明

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