eXtremeComponents参考文档(二)

15.1.3. RowTagRowTag<ec:row> 现在被需要,它被用来替代columns。 现在看来它一直被需要。它不知道表中到底有多少列,最近重构的时候我通过 Table -> Row -> Column使结构固定来合并得到更好的灵活性。将来我可能提供更多的 特性,因为我知道eXtremeTable有着清晰的架构。

典型的eXtremeTable如下:

<ec:table items="presidents" var="pres" action="${pageContext.request.contextPath}/presidents.run" > <ec:row> <ec:column property="name"/> <ec:column property="term"/> </ec:row></ec:table>
15.1.4. AutoGenerateColumnsAutoGenerateColumns得到了很大的提高,现在你只需要设置你需要的属性。 当你添加列到ColumnHandler使,defaults将别自动调用。

AutoGenerateColumns为singleton并且不是线程安全的,因此不要定义任何类变量。

现在它的实现可能如下:

public class AutoGenerateColumnsImpl implements AutoGenerateColumns { public void addColumns(TableModel model) { Iterator iterator = columnsToAdd().iterator(); while (iterator.hasNext()) { Map columnToAdd = (Map) iterator.next(); Column column = new Column(model); column.setProperty((String) columnToAdd.get(PROPERTY)); column.setCell((String) columnToAdd.get(CELL)); model.getColumnHandler().addAutoGenerateColumn(column); } }}
15.1.5. Extended AttributesaddExtendedAttributes方法重命名使得如何使用这个特性更清晰。 因此RowTag的addExtendedAttributes现在变为addRowAttributes,ColumnTag变 为addColumnAttributes,TableTag变为addTableAttributes,ExportTag变 为addExportAttributes。另外你参考正确的model bean(它的实现更清晰), 将知道如何添加属性到你的cell、view.....

使用ExportCsvTag的示例如下:

public void addExportAttributes(Export export) { String view = export.getView(); if (StringUtils.isBlank(view)) { export.setView(TableConstants.CSV); export.setImageName(TableConstants.CSV); } export.addAttribute(CsvView.DELIMITER, getDelimiter());}
为了得到delimiter属性值你只需要从Export bean中get它:

Export export = model.getExportHandler().getCurrentExport();String delimiter = export.getAttributeAsString(DELIMITER);
现在你需要在ExportTag中覆盖它,你只需要调用setter方法。如果是新的属性,那么使用 可以和前一版一样使用addAttribute()方法。为了得到值,首先从ExportHandler得到Export, 然后调用需要的getter方法。这和使用其它tags一样。

在RowTag和ColumnTag中增加了两个新的callback方法:modifyRowAttributes和 modifyColumnAttributes,因此你可以在rows/columns被处理时改变属性值。

15.1.6. TableTag的collection属性TableTag的collection属性被删除,现在变为三个新属性:tableId、items和var。 因为我按照标准的JSTL命名,你应该能够根据这些名称知道他们的作用。tableId属性 被用来作为表的唯一标识,items属性用来表示从各种servlet的scopes里取得的集合, var属性表示你将使用EL编写脚本的名称。

依赖你的需要来决定如何使用新的属性,tableId用来唯一标识表。如果你的页面上只使用了 一个eXtremeTable并且不使用Limit特性,那么你根本不需要定义它。默认的表示名为'ec';如果使用 Limit特性你也可以使用'ec'这个名称。然而,如果的一个JSP页面上同时使用两个eXtremeTables你就 需要使用tableId来唯一标识他们。var属性被用来你将使用EL编写脚本的名称。items属性用来表示从 各种servlet的scopes里取得的集合,而且现在非常健壮。你现在能nest集合到另外的对象,或者nest你想的 深度。

取得集合的语法如下:

<ec:table items="command.myObject.myCol" />
本示例将从命令对象(command object)取得myCol集合。

<ec:table items="myCol" />
本示例中将根据名称自动取得集合,就像以前版本的collection属性一样。

15.1.7. BaseModelBaseModel被重命名为TableModel,这是因为已经不需要一个基础包(base package)了,这也 意味着不再需要BaseModel了。

15.1.8. Properties和ResourceBundleweb.xml文件中使用extremecomponentsPreferencesLocation属性取代extremecomponentsPropertiesLocation属性, properties现在被Preferences接口控制。在以后的版本,我将提供可选的xml文件配置。

eXtremeTable不再默认在顶层类路径(top level classpath)寻找 extremecomponents.properties文件。你应该在web.xml中使用设置context-param属性的 值为extremecomponentsPreferencesLocation,这将更为通用。

web.xml文件中使用extremecomponentsMessagesLocation属性取代extremecomponentsResourceBundleLocation属性, internationalization现在被Messages接口控制。

Properties和ResourceBundle属性根据table、row、column、export和filterare区分开。 在以前版本中每个属性都以'table'开头,现在每个属性关联到被使用的标签。另外poperty不再需要使用奇怪的下划线语法, 而是使用dot来强调。

下面为properties文件的示例:

table.imagePath=/extremesite/images/*.giftable.rowsDisplayed=12column.parse.date=yyyy-MM-ddcolumn.format.date=MM/dd/yyyycolumn.format.currency=$###,###,##0.00
[英文的属性文件示例如下:]

statusbar.resultsFound={0} results found, displaying {1} to {2}statusbar.noResultsFound=There were no results found.toolbar.firstPageTooltip=First Pagetoolbar.lastPageTooltip=Last Pagetoolbar.prevPageTooltip=Previous Pagetoolbar.nextPageTooltip=Next Pagetoolbar.filterTooltip=Filtertoolbar.clearTooltip=Cleartoolbar.clearText=Cleartoolbar.firstPageText=Firsttoolbar.lastPageText=Lasttoolbar.nextPageText=Nexttoolbar.prevPageText=Prevtoolbar.filterText=Filtercolumn.headercell.sortTooltip=Sort Bycolumn.calc.total=Totalcolumn.calc.average=Average
15.1.9. pageContextTableModel (以前的BaseModel)不再直接访问pageContext,取而代之的是使用Context接口, 默认的被pageContext支持。直接访问pageContext是一个不好的实现,Context提供你需要从不同servlet scopes中 取得需要属性值的所有方法。然而,如果你需要直接访问背后的对象,可以使用getContextObject()方法。

15.1.10. Limit和LimitFactoryLimit和LimitFactory现在都是接口,以前版本的实现不如我想象的简单。然而, Limit对象的方法命名和以前版本的一样,因此你以前的代码也能很好的工作。

我两个Limit实现重构为一个,但是仍有两个LimitFactory实现, 从coding的观点用户只要使用一个 实现,但是它必须兼容以前的版本。现在只有一个Limit实现我重命名为TableLimit。同时,因为Limit特性 依赖Context而不是request,我重命名工厂类(TableLimitFactory)来reflect它。

Limit在导出时正确地显示行信息,Limit具有一个isExported()方法。

使用Limit和LimitFactory的示例如下:

Context context = new HttpServletRequestContext(request);LimitFactory limitFactory = new TableLimitFactory(context, tableId);Limit limit = new TableLimit(limitFactory);
设置row属性,仅设置totalRows和默认的行显示:

limit.setRowAttributes(totalRows, DEFAULT_ROWS_DISPLAYED);
RequestLimitFactory具有另一个如果没有指定tableId将设置为ec的构造函数:

Context context = new HttpServletRequestContext(request);LimitFactory limitFactory = new TableLimitFactory(context);
15.1.11. TableTag的saveFilterSort属性saveFilterSort属性被state属性取代,state属性参照State接口并能插接不通的关于 如何保存表状态的实现。

State接口如下:

public interface State { public void saveParameters(TableModel model, Map parameters); public Map getParameters(TableModel model);}
表新增了两个属性:state和stateAttr。state属性使用预设的四种 状态(default、notifyToDefault、persist和notifyToPersist)之一, 你也可以插接自己的实现。default状态不维持任何状态;persist状态没有任何参数传入,将一直维持表的状态; notifyToDefault状态将一直维持表的状态直到你传入参数告诉它回到default状态;notifyToPersist状态 将一直维持当前状态直到你传入参数告诉它维持persisted状态。stateAttr为指定参数提供了一条途径,你 也可以使用属性文件在全局范围内指定它。为了向后兼容,默认参数一直为useSessionFilterSort。

如果你想state按照不同方式工作你只要实现State接口,然后使用TableTag的state属性来指定实现类的 全路径。

15.1.12. ColumnTag的showTotal属性列新增了两个属性:calc和calcTitle:

<ec:column property="data" calc="total" calcTitle="Total:" />
calc属性实现具有唯一方法的Calc接口:

public interface Calc { public Number getCalcResult(TableModel model, Column column);}
它传入model和column,并返回一个Number型的值。默认的实现为总计和平均值。

为了使用定制的Calc,只需要使用ColumnTag的calc属性来指定实现Calc接口的实现类的 全路径。

Calc为singleton并且不是线程安全的,因此不要定义任何类变量。

showTotal因为不再适用在新版中被删除,我也删除了表中的totalTitle。

15.1.13. Image名search图片名从search变为filter。

15.1.14. FormTag / InputTag DeprecatedFormTag和InputTag现在为deprecated。他们在新的html视图(view)中不再被使用。

15.1.15. RetrieveRowsCallbacks、FilterRowsCallback、SortRowsCallbackCallbacks为singleton并且不是线程安全的,因此不要定义任何类变量。

Chapter 16. Tag Attributes
16.1. TableTag
Table 16.1.

Name Description
action The URI that will be called when the filter, sort and pagination is used.
autoIncludeParameters Specify whether or not to automatically include the parameters, as hidden inputs, passed into the JSP.
border The table border attribute. The default is 0.
cellpadding The table cellpadding attribute. The default is 0.
cellspacing The table cellspacing attribute. The default is 0.
filterable Specify whether or not the table is filterable. Boolean value with the default being true.
filterRowsCallback A fully qualified class name to a custom FilterRowsCallback implementation. Could also be a named type in the preferences. Used to filter the Collection of Beans or Collection of Maps.
form The reference to a surrounding form element.
imagePath The path to find the images. For example imagePath=/extremesite/images/*.png is saying look in the image directory for the .png images.
intercept A fully qualified class name to a custom InterceptTable implementation. Could also be a named type in the preferences. Used to add table attributes.
items Reference the collection that will be retrieved.
locale The locale for this table. For example fr_FR is used for the French translation.
method Used to invoke the table action using a POST or GET.
onsubmit The javascript onsubmit action for the table.
retrieveRowsCallback A fully qualified class name to a custom RetrieveRowsCallback implementation. Could also be a named type in the preferences. Used to retrieve the Collection of Beans or Collection of Maps.
rowsDisplayed The number of rows to display in the table.
scope The scope (page, request, session, or application) to find the Collection of beans or Collection of Maps defined by the collection attribute.
showPagination Specify whether or not the table should use pagination. Boolean value with the default being true.
showExports Specify whether or not the table should use the exports. Boolean value with the default being true.
showStatusBar Specify whether or not the table should use the status bar. Boolean value with the default being true.
showTooltips Specify whether or not to show the tooltips. Boolean value with the default being true.
sortRowsCallback A fully qualified class name to a custom SortRowsCallback implementation. Could also be a named type in the preferences. Used to sort the Collection of Beans or Collection of Maps.
sortable Specify whether or not the table is sortable. Boolean value with the default being true.
state The table state to use when returning to a table. Acceptable values are default, notifyToDefault, persist, notifyToPersist.
stateAttr The table attribute used to invoke the state change of the table.
style The css inline style sheet.
styleClass The css class style sheet.
tableId The unique identifier for the table.
theme The theme to style the table. The default is eXtremeTable.
title The title of the table. The title will display above the table.
var The name of the variable to hold the current row bean.
view Generates the output. The default is the HtmlView to generate the HTML. Also used by the exports to generate XLS-FO, POI, and CSV.
width Width of the table.

16.2. RowTag
Table 16.2.

Name Description
highlightClass The css class style sheet when highlighting rows.
highlightRow Used to turn the highlight feature on and off. Acceptable values are true or false. The default is false.
intercept A fully qualified class name to a custom InterceptRow implementation. Could also be a named type in the preferences. Used to add or modify row attributes.
onclick The javascript onclick action
onmouseout The javascript onmouseout action
onmouseover The javascript onmouseover action
style The css inline style sheet.
styleClass The css class style sheet.

16.3. ColumnTag
Table 16.3.

Name Description
alias Used to uniquely identify the column when the same property is used for more than one column.
calc A fully qualified class name to a custom Calc implementation. Could also be a named type in the preferences. Used to do math on a column.
calcTitle The title of the calc.
cell Display for the column. The valid values are display, currency, rowCount, and date. The default value is display. The cell can also be a fully qualified class name to a custom Cell. Be sure to implement the Cell interface or extend AbstractCell if making a custom cell.
escapeAutoFormat Specify whether auto format of value will be skipped. False by default, and is only effective if autoformatting is implement in the view.
filterable Specify whether or not the column should be filterable. Acceptable values are true or false. The default is to use the value for the table filterable attribute.
filterCell Displays the filter column. The valid values are filter and droplist. The default is filter. The cell can also be a fully qualified class name to a custom cell.
filterClass The css class style sheet used to define what the table filter column looks like.
filterStyle The css class style sheet to use for the filter column.
format The format to use for the cell. For instance if used with a date cell then the format can be MM/dd/yyyy.
headerCell Display for the header column. The default is header. The cell can also be a fully qualified class name to a custom cell.
headerClass The css class style sheet used to define what the table header column looks like.
headerStyle The css class style sheet to use for the header column.
intercept A fully qualified class name to a custom InterceptColumn implementation. Could also be a named type in the preferences. Used to add or modify column attributes.
parse Used if the format needs to be interpreted. For instance, a date needs to be parsed in the specific format, such as MM-dd-yyyy.
property The bean attribute to use for the column.
sortable Specify whether or not the column should be sortable. The acceptable values are true or false. The default is to use the value for the table sortable attribute.
style The css inline style sheet.
styleClass The css class style sheet.
title The display for the table column header. If the title is not specified then it will default to the name of the property, changing the camelcase syntax to separate words.
value The value for the column. If the value attribute is not specifed then it will be retrieved automatically using the property attribute. The value can also be defined within the column body.
viewsAllowed The comma separated list of views that this column will be used in.
viewsDenied The comma separated list of views that this column will not be used in.
width Specify the column width.

16.4. ExportTag
Table 16.4.

Name Description
fileName The name of the export file.
imageName The image name.
intercept A fully qualified class name to a custom InterceptExport implementation. Could also be a named type in the preferences. Used to add or modify export attributes.
view A fully qualified class name to a custom View implementation. Could also be a named type in the preferences. Default types are pdf, xls, or csv.
viewResolver A fully qualified class name to a custom ViewResolver implementation. Could also be a named type in the preferences. Default types are pdf, xls, or csv.
text The text for the export view.
tooltip The tooltip that shows up when you mouseover the export image.

16.5. ExportXlsTag
Table 16.5.

Name Description
fileName The name of the export file.
imageName The image name.
intercept A fully qualified class name to a custom InterceptExport implementation. Could also be a named type in the preferences. Used to add or modify export attributes.
view A fully qualified class name to a custom View implementation. Could also be a named type in the preferences. Default types are pdf, xls, or csv.
viewResolver A fully qualified class name to a custom ViewResolver implementation. Could also be a named type in the preferences. Default types are pdf, xls, or csv.
text The text for the export view.
tooltip The tooltip that shows up when you mouseover the export image.

16.6. ExportCsvTag
Table 16.6.

Name Description
delimiter What to use as the file delimiter. The default is a comma.
fileName The name of the export file.
imageName The image name.
intercept A fully qualified class name to a custom InterceptExport implementation. Could also be a named type in the preferences. Used to add or modify export attributes.
view A fully qualified class name to a custom View implementation. Could also be a named type in the preferences. Default types are pdf, xls, or csv.
viewResolver A fully qualified class name to a custom ViewResolver implementation. Could also be a named type in the preferences. Default types are pdf, xls, or csv.
text The text for the export view.
tooltip The tooltip that shows up when you mouseover the export image.

16.7. ExportPdfTag
Table 16.7.

Name Description
headerBackgroundColor The background color on the header column.
headerColor The font color for the header column.
headerTitle The title displayed at the top of the page.
fileName The name of the export file.
imageName The image name.
intercept A fully qualified class name to a custom InterceptExport implementation. Could also be a named type in the preferences. Used to add or modify export attributes.
view A fully qualified class name to a custom View implementation. Could also be a named type in the preferences. Default types are pdf, xls, or csv.
viewResolver A fully qualified class name to a custom ViewResolver implementation. Could also be a named type in the preferences. Default types are pdf, xls, or csv.
text The text for the export view.
tooltip The tooltip that shows up when you mouseover the export image.

16.8. ColumnsTag
Table 16.8.

Name Description
autoGenerateColumns A fully qualified class name to a custom AutoGenerateColumns implementation. Could also be a named type in the preferences. Used to generate columns on the fly.

16.9. ParameterTag
Table 16.9.

Name Description
name The name of the parameter.
value The value of the parameter.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值