📄 tabletagutils.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.extremecomponents.table.bean.Table;import org.extremecomponents.table.core.BaseModel;import org.extremecomponents.table.core.BaseProperties;import org.extremecomponents.table.core.TableModelUtils;import org.extremecomponents.table.core.TableProperties;import org.extremecomponents.table.core.TableResourceBundle;import org.extremecomponents.table.handler.ViewHandler;/** * 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 */final class TableTagUtils { static String getTableId(String tableId, String collection) { if (StringUtils.isNotEmpty(tableId)) { return tableId; } if (StringUtils.isNotEmpty(collection)) { return collection; } return Table.EXTREME_COMPONENTS; } static String getVar(String var, String tableId) { if (StringUtils.isNotEmpty(var)) { return var; } return tableId; } static Object getItems(Object items, String collection) { if (items != null) { return items; } if (StringUtils.isNotBlank(collection)) { return collection; } return null; } static String getStyleClass(BaseModel model, String styleClass) { if (StringUtils.isEmpty(styleClass)) { return model.getProperties().getProperty(BaseProperties.STYLE_CLASS); } return styleClass; } static String getBorder(BaseModel model, String border) { if (StringUtils.isEmpty(border)) { return model.getProperties().getProperty(BaseProperties.BORDER); } return border; } static String getCellpadding(BaseModel model, String cellpadding) { if (StringUtils.isEmpty(cellpadding)) { return model.getProperties().getProperty(BaseProperties.CELLPADDING); } return cellpadding; } static String getCellspacing(BaseModel model, String cellspacing) { if (StringUtils.isEmpty(cellspacing)) { return model.getProperties().getProperty(BaseProperties.CELLSPACING); } return cellspacing; } static String getRowsDisplayed(BaseModel model, String rowsDisplayed) { if (StringUtils.isBlank(rowsDisplayed)) { return model.getProperties().getProperty(BaseProperties.ROWS_DISPLAYED); } return rowsDisplayed; } static String getMaxRowsDisplayed(BaseModel model) { return model.getProperties().getProperty(BaseProperties.MAX_ROWS_DISPLAYED); } static String getMedianRowsDisplayed(BaseModel model) { return model.getProperties().getProperty(BaseProperties.MEDIAN_ROWS_DISPLAYED); } static String getFilterable(BaseModel model, String filterable) { if (StringUtils.isEmpty(filterable)) { return model.getProperties().getProperty(BaseProperties.FILTERABLE); } return filterable; } static String getShowPagination(BaseModel model, String showPagination) { if (StringUtils.isEmpty(showPagination)) { return model.getProperties().getProperty(BaseProperties.SHOW_PAGINATION); } return showPagination; } static String getShowExports(BaseModel model, String showExports) { if (StringUtils.isEmpty(showExports)) { return model.getProperties().getProperty(BaseProperties.SHOW_EXPORTS); } return showExports; } static String getShowStatusBar(BaseModel model, String showStatusBar) { if (StringUtils.isEmpty(showStatusBar)) { return model.getProperties().getProperty(BaseProperties.SHOW_STATUS_BAR); } return showStatusBar; } static String getImagePath(BaseModel model, String imagePath) { if (StringUtils.isBlank(imagePath)) { String resourceValue = model.getResourceBundle().getResource(TableResourceBundle.IMAGE_PATH); if (resourceValue != null) { return resourceValue; } return model.getProperties().getProperty(BaseProperties.IMAGE_PATH); } return imagePath; } static String getSortable(BaseModel model, String sortable) { if (StringUtils.isEmpty(sortable)) { return model.getProperties().getProperty(BaseProperties.SORTABLE); } return sortable; } static String getTitle(BaseModel model, String title) { if (TableModelUtils.isResourceBundleProperty(title)) { String resourceValue = model.getResourceBundle().getResource(title); if (resourceValue != null) { return resourceValue; } } return title; } static String getWidth(BaseModel model, String width) { if (StringUtils.isEmpty(width)) { return model.getProperties().getProperty(BaseProperties.WIDTH); } return width; } static String getAutoIncludeParameters(BaseModel model, String autoIncludeParameters) { if (StringUtils.isEmpty(autoIncludeParameters)) { return model.getProperties().getProperty(BaseProperties.AUTO_INCLUDE_PARAMETERS); } return autoIncludeParameters; } static String getFilterRowsCallback(BaseModel model, String filterRowsCallback) { if (StringUtils.isEmpty(filterRowsCallback)) { return model.getProperties().getProperty(BaseProperties.FILTER_ROWS_CALLBACK); } return filterRowsCallback; } static String getRetrieveRowsCallback(BaseModel model, String retrieveRowsCallback) { if (StringUtils.isEmpty(retrieveRowsCallback)) { return model.getProperties().getProperty(BaseProperties.RETRIEVE_ROWS_CALLBACK); } return retrieveRowsCallback; } static String getSortRowsCallback(BaseModel model, String sortRowsCallback) { if (StringUtils.isEmpty(sortRowsCallback)) { return model.getProperties().getProperty(BaseProperties.SORT_ROWS_CALLBACK); } return sortRowsCallback; } static String getView(String view) { if (StringUtils.isEmpty(view)) { return ViewHandler.HTML; } return view; } static String getLocale(BaseModel model, String locale) { if (StringUtils.isEmpty(locale)) { return model.getProperties().getProperty(BaseProperties.LOCALE); } return locale; } static Locale getLocaleObject(PageContext pageContext, String locale) { if (StringUtils.isBlank(locale)) { return pageContext.getRequest().getLocale(); } Locale result = null; String parts[] = StringUtils.split(locale, "_"); String language = parts[0]; if (parts.length == 2) { String country = parts[1]; result = new Locale(language, country); } else { result = new Locale(language, ""); } return result; } static String getResourceBundleLocation(PageContext pageContext) { String result = pageContext.getServletContext().getInitParameter(Table.RESOURCE_BUNDLE_LOCATION); if (StringUtils.isNotBlank(result)) { return result; } return null; } 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 + -