📄 tabletag.java
字号:
public void setSortable(String sortable) { this.sortable = sortable; } /** * @jsp.attribute description="The title of the table. The title will * display above the table." required="false" * rtexprvalue="true" */ public String getTitle() { String title = TagUtils.evaluateExpressionAsString("title", this.title, this, pageContext); return TableTagUtils.getTitle(model, title); } public void setTitle(String title) { this.title = title; } /** * @jsp.attribute description="The css inline style sheet." required="false" * rtexprvalue="true" */ public String getStyle() { return TagUtils.evaluateExpressionAsString("style", style, this, pageContext); } public void setStyle(String style) { this.style = style; } /** * @jsp.attribute description="Width of the table." required="false" * rtexprvalue="true" */ public String getWidth() { String width = TagUtils.evaluateExpressionAsString("width", this.width, this, pageContext); return TableTagUtils.getWidth(model, width); } public void setWidth(String width) { this.width = width; } /** * @jsp.attribute description="Save the table state as filtered and/or * sorted." required="false" rtexprvalue="true" */ public String getSaveFilterSort() { return TagUtils.evaluateExpressionAsString("saveFilterSort", saveFilterSort, this, pageContext); } public void setSaveFilterSort(String saveFilterSort) { this.saveFilterSort = saveFilterSort; } /** * @jsp.attribute description="Specify whether or not to automatically * included the parameters." required="false" * rtexprvalue="true" */ public String getAutoIncludeParameters() { String autoIncludeParameters = TagUtils.evaluateExpressionAsString("autoIncludeParameters", this.autoIncludeParameters, this, pageContext); return TableTagUtils.getAutoIncludeParameters(model, autoIncludeParameters); } public void setAutoIncludeParameters(String autoIncludeParameters) { this.autoIncludeParameters = autoIncludeParameters; } /** * @jsp.attribute description="The title of the total row. The title will * display between the body and the total row. This value * will default to Totals if not specified." required="false" * rtexprvalue="true" */ public String getTotalTitle() { return TagUtils.evaluateExpressionAsString("totalTitle", totalTitle, this, pageContext); } public void setTotalTitle(String totalTitle) { this.totalTitle = totalTitle; } /** * @jsp.attribute description="Filter the List of Beans or List of Maps. * Could also be a fully qualified class name to a custom * implemenation." required="false" rtexprvalue="true" */ public String getFilterRowsCallback() { String filterRowsCallback = TagUtils.evaluateExpressionAsString("filterRowsCallback", this.filterRowsCallback, this, pageContext); return TableTagUtils.getFilterRowsCallback(model, filterRowsCallback); } public void setFilterRowsCallback(String filterRowsCallback) { this.filterRowsCallback = filterRowsCallback; } /** * @jsp.attribute description="Return the List of Beans or List of Maps. * Could also be a fully qualified class name to a custom * implemenation." required="false" rtexprvalue="true" */ public String getRetrieveRowsCallback() { String retrieveRowsCallback = TagUtils.evaluateExpressionAsString("retrieveRowsCallback", this.retrieveRowsCallback, this, pageContext); return TableTagUtils.getRetrieveRowsCallback(model, retrieveRowsCallback); } public void setRetrieveRowsCallback(String retrieveRowsCallback) { this.retrieveRowsCallback = retrieveRowsCallback; } /** * @jsp.attribute description="Sort the List of Beans or List of Maps. Could * also be a fully qualified class name to a custom * implemenation." required="false" rtexprvalue="true" */ public String getSortRowsCallback() { String sortRowsCallback = TagUtils.evaluateExpressionAsString("sortRowsCallback", this.sortRowsCallback, this, pageContext); return TableTagUtils.getSortRowsCallback(model, sortRowsCallback); } public void setSortRowsCallback(String sortRowsCallback) { this.sortRowsCallback = sortRowsCallback; } /** * @jsp.attribute description="Generates the output. The default is the * HtmlView to generate the HTML. Also used by the exports to * generate XLS-FO, POI, and CSV." required="false" * rtexprvalue="true" */ public String getView() { String view = TagUtils.evaluateExpressionAsString("view", this.view, this, pageContext); return TableTagUtils.getView(view); } public void setView(String view) { this.view = view; } /** * @jsp.attribute description="Get the locale for this table." * required="false" rtexprvalue="true" */ public String getLocale() { String locale = TagUtils.evaluateExpressionAsString("locale", this.locale, this, pageContext); return TableTagUtils.getLocale(model, locale); } public void setLocale(String locale) { this.locale = locale; } public int doStartTag() throws JspException { try { iterator = null; Table table = doStartTagInternal(); model.getTableHandler().addTable(table); // load up enough attributes to fire up the properties file table.addAttribute(Table.PROPERTIES_LOCATION, TableTagUtils.getPropertiesLocation(pageContext)); model.getProperties().init(); // load up enough attributes to fire up the resource bundle table.addAttribute(Table.LOCALE, TableTagUtils.getLocaleObject(pageContext, getLocale())); table.addAttribute(Table.RESOURCE_BUNDLE_LOCATION, TableTagUtils.getResourceBundleLocation(pageContext)); model.getResourceBundle().init(); // load up enough attributes to fire up the parameter registry table.addAttribute(Table.TABLE_ID, getTableId()); table.addAttribute(Table.AUTO_INCLUDE_PARAMETERS, getAutoIncludeParameters()); table.addAttribute(Table.SAVE_FILTER_SORT, getSaveFilterSort()); model.getRegistry().init(pageContext); // now load up everything else table.addAttribute(Table.SCOPE, getScope()); table.addAttribute(Table.ACTION, getAction()); table.addAttribute(Table.ITEMS, getItems()); table.addAttribute(Table.VAR, getVar()); table.addAttribute(Table.STYLE_CLASS, getStyleClass()); table.addAttribute(Table.ID, getId()); table.addAttribute(Table.BORDER, getBorder()); table.addAttribute(Table.CELLPADDING, getCellpadding()); table.addAttribute(Table.CELLSPACING, getCellspacing()); table.addAttribute(Table.FILTERABLE, getFilterable()); table.addAttribute(Table.SHOW_PAGINATION, getShowPagination()); table.addAttribute(Table.SHOW_EXPORTS, getShowExports()); table.addAttribute(Table.SHOW_STATUS_BAR, getShowStatusBar()); table.addAttribute(Table.IMAGE_PATH, getImagePath()); table.addAttribute(Table.SORTABLE, getSortable()); table.addAttribute(Table.TITLE, getTitle()); table.addAttribute(Table.STYLE, getStyle()); table.addAttribute(Table.WIDTH, getWidth()); table.addAttribute(Table.TOTAL_TITLE, getTotalTitle()); table.addAttribute(Table.RETRIEVE_ROWS_CALLBACK, getRetrieveRowsCallback()); table.addAttribute(Table.FILTER_ROWS_CALLBACK, getFilterRowsCallback()); table.addAttribute(Table.SORT_ROWS_CALLBACK, getSortRowsCallback()); table.addAttribute(Table.VIEW, getView()); table.addAttribute(Table.ROWS_DISPLAYED, getRowsDisplayed()); table.addAttribute(Table.MEDIAN_ROWS_DISPLAYED, TableTagUtils.getMedianRowsDisplayed(model)); table.addAttribute(Table.MAX_ROWS_DISPLAYED, TableTagUtils.getMaxRowsDisplayed(model)); addExtendedAttributes(table); pageContext.setAttribute(ROWCOUNT, "0"); } catch (Exception e) { throw new JspException("TableTag.doStartTag() Problem: " + ExceptionUtils.formatStackTrace(e)); } return EVAL_BODY_INCLUDE; } /** * Meant to be overridden. Set specific model attributes. */ Table doStartTagInternal() { model = new TableModel(pageContext); Table table = new Table(); return table; } /** * Two things need to be accomplished here. First, need to iterate once over * the columns to load up all the attributes. Second, need to iterate over * the columns as many times as specified by the rowsDisplayed attribute so * the columns row can be resolved. On each iteration over the columns the * current bean in the collection is passed via the pageScope. */ public int doAfterBody() throws JspException { try { if (iterator == null) { iterator = getModel().execute().iterator(); } if (iterator != null && iterator.hasNext()) { model.getRowHandler().increaseRowCount(); Object bean = iterator.next(); model.setCurrentCollectionBean(bean); pageContext.setAttribute(ROWCOUNT, String.valueOf(model.getRowHandler().getRow().getRowCount())); pageContext.setAttribute(model.getTableHandler().getTable().getVar(), bean); return EVAL_BODY_AGAIN; } } catch (Exception e) { throw new JspException("TableTag.doAfterBody() Problem: " + ExceptionUtils.formatStackTrace(e)); } return SKIP_BODY; } public int doEndTag() throws JspException { try { if (!model.getColumnHandler().hasMetatData()) { GenerateColumns.autoSetColumns(this, model.execute()); } Object output = model.getViewHandler().getView().afterBody(model); if (model.getExportHandler().invokeExport()) { pageContext.getRequest().setAttribute(ExportHandler.EXPORT_DATA, output); } else { pageContext.getOut().println(output); } } catch (Exception e) { throw new JspException("TableTag.doEndTag() Problem: " + ExceptionUtils.formatStackTrace(e)); } model.destroy(); return EVAL_PAGE; } public void addExtendedAttributes(Attributes attributes) throws JspException { } public void doCatch(Throwable e) throws Throwable { throw new JspException("TableTag Problem: " + ExceptionUtils.formatStackTrace(e)); } public void doFinally() { iterator = null; model = null; } public void release() { model = null; iterator = null; id = null; collection = null; scope = null; action = null; styleClass = null; border = null; cellpadding = null; cellspacing = null; rowsDisplayed = null; filterable = null; showPagination = null; showStatusBar = null; imagePath = null; sortable = null; title = null; style = null; width = null; saveFilterSort = null; autoIncludeParameters = null; retrieveRowsCallback = null; filterRowsCallback = null; sortRowsCallback = null; view = null; locale = null; var = null; super.release(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -