快捷搜索:  as  test  1111  test aNd 8=8  test++aNd+8=8  as++aNd+8=8  as aNd 8=8

新葡的京集团350vip_酒文化网进入



Display标签外部排序与分页(External Paging and Sorting)小序

大年夜家都知道,Display标签处置惩罚大年夜数据量的时刻,排序会反映迟顿。是以标签的设计者供给了外部排序功能,也便是由用户自己来处置惩罚排序逻辑,我参照字面及实际的意思,将external译为外部排序,好象不太准确,谁有更好的译法,请奉告我。

这是Display官方文档的译文,第一次翻译E文,不当之处见谅。特意以中英文对比的形式,大年夜家对比着来理解。有两句话没有译出来,谁知道怎么译请奉告我。

The default behavior of displaytag is working with a full list, handling sorting and paging trasparently. Sometimes, however, you could need to give displaytag only the records displayed, handling sorting and paging by yourself (this is what we call "partial list support").

displaytag标签的默认行径是应用整个的数据列表,透明的进行排序与分页。可是无意偶尔,你可能必要displaytag标签仅显示必要显示的数据,自己来处置惩罚排序与分页(这我们称之为“部分列表支持”(这个译法可能不太贴切,大年夜家明白就行,也便是仅应用整个数据列表中的))。(作者:wallimn 电邮:wallimn@sohu.com 博客:http://blog.csdn.net/wallimn)

Displaytag 1.1 offers two alternative ways for working with partial lists:

Displaytag 1.1版供给两种可选的要领来处置惩罚部分列表支持:

displaytag

the first one uses the valuelist pattern, and requires that the object that you give to displaytag implements the org.displaytag.pagination.PaginatedList interface. You can pass this object to displaytag as an usual list, and it will extract paging and sorting information from it. This way is more recommended if you have to build your backend layer 新葡的京集团350vipand you can easily follow this pattern.

第一种应用valuelist模式,要求通报给Displaytag标签的工具实现org.displaytag.pagination.PaginatedList接口。这个工具可以象一个一样平常的数据列表一样通报给Displaytag标签,Displaytag标签将从中提取分页信息及排序信息。假如自己要构建办事端,这种模式是易于应用的,保举采纳。

a second way, recommended if you only have to use partial list for few tables that show a performance problem using full lists, is passing all the needed parameters as separate tag attributes (recors to be shown, page number, total number of records...)

第二种要领,在因为机能问题,仅需应用部分列表显示为数不多的几个神色况下,保举采纳。通报所有必要的参数作为分开的标签属性(如:页码、记录总数)。

Using the Valuelist pattern

Valuelist模式

If the object passed to the displaytag as a list is in fact an instance of org.displaytag.pagination.PaginatedList (and not a collection), displaytag will assume that the list is externally sorted and paginated. Implementing this interface is trivial, and an adapter over existing classes can easily be written. See the org.displaytag.pagination.PaginatedList javadocs for more details.

假如通报给displaytag标签的列体实际上是org.displaytag.pagination.PaginatedList的实例(也便是不是聚拢),标签会觉得这个列表是外部排好序、分好页的。若何实现org.displaytag.pagination.PaginatedList接口就没有需要先容了,可以很轻易的根据已经存在的类改写。可以查看javadocs的相关部分懂得更多细节。

In order for the generated pagination and sort links to be "understandable" by the application, they are not generated the same way as for a traditional DisplayTag table. Indeed, since the table is externally sorted and paginated, the ap新葡的京集团350vipplication must be able to easily get the sort and pagination parameters, without having to decode the DisplayTag encoded parameters.

这种模式下,为了孕育发生可被利用“理解”的分页及排序链接,应用与传统DisplayTag表格不合的措施。实际上,既然由外部排序与分页,利用必须能够轻易地获得排序与分页参数,而不是去解码由标签编码的参数。

These sort and pagination links are generated based on additional properties. These properties can be overridden using, in order to be able to have different sort of page parameters in the application, or to have multiple tables in a single HTML page.

排序及分页的链接是基于额外的属性。这些参数可以应用改写,以便能在一个HTML页面中处置惩罚不合的排序参数,或者处置惩罚多个表

If the default values of these properties are used, the href of the sort links will look like this:

假如这些属机能缺省值,排序链接地址形式如下所示:

http://foo.bar.com/context/requestUri?sort=name&dir=asc&originalParameters=originalValues.The href of the pagination links will look like this:

分页链接地址形式如下:

http://foo.bar.com/context/requestUri?sort=name&dir=asc&page=5&originalParameters=originalValuesWithout implementing the PaginatedList interface

不实现PaginatedList接口的办理法子

External sort

外部排序

When using the sort="external" property you are telling DisplayTag新葡的京集团350vip that your list is already sorted according to some specific column before the tag gets it. This is a must when used with partial lists as we will see below, however you can use it by itself. A new property named sortName has been addeed to the column tag. The purpose of this property is for convenience when writing the backend code that actually does the sorting of the data. For example the header link for the column with property id in the sample code above will render a link containing d-(encoded table id)-s=id. If you remove the sortName property from the column the link will instead contain d-(encoded table id)-s=0, which is the index of the column rather than the name. Once again it is solely for convenience.

应用sort="external"属性,奉告DisplayTag标签在它获取数据列表前,列表已经根据特定的列表排好序了。经由过程下面的例子可以看到,当应用部分列表的时刻这是必须的,然则......(这句话没有搞懂怎么翻译,原文为:however you can use it by itself)。列标签添加了一个新的属性:sortName。这是为了便于后台数据排序代码进行处置惩罚。例如,上例中id列的排序链接会包孕d-(encoded table id)-s=id,假如不应用sortName属性,排序链接响应的会变为包孕d-(encoded table id)-s=0,留意,应用的是列的序号而不是列名。再重申一次,这只是为了方便后台代码的编写。

The first time you access a jsp with a DisplayTag in it, there are two ways for the tag to know how your data is sorted. Firstly it will check for a request parameter d-(encoded table id)-s. If that parameter exists, and its value matches the sortName of one of the declared column tags, then when it is rendered to html it will set the matching column as being sorted. If that parameter does not exist it will examine the defaultsort property of the table tag, if it exists then it will render the corresponding column as sorted. Otherwise no column will be rendered as being sorted. So really you have two options. Set your backend to sort your data based on a set column when there is no request parameter, and set your defaultsort parameter to match that column. Or ensure that all links pointing to your page that houses the DisplayTag have a d-(encoded table id)-s=(column index or sortName) parameter in them.

第一次在页面中应用DisplayTag标签的时刻,标签有两种要领知道数据是若何排序的。第一种要领为:检测 d-(encoded table id)-s参数,假如参数存在,并且与某一列的sortName属性同等辞,那么标签就以匹配列为排序列来天生HTML代码。假如参数不存在,就反省缺省的排序列,假如存在就以天生以缺省列进行排序的HTML代码。不满意以上环境,就天生的HTML代码是不以任何列进行排序的。以是你有两个选择,当无request参数的时刻,后台代码应用特定的列时行排序,然后defaultsor应用该列为默认排序列;或者使所有建筑DisplayTag标签的链接都包孕参数:d-(encoded table id)-s=(column index or sortName)。

To determine the request parameter name for column sorting you can do:

可以经由过程下面的措施获取request参数的名字:

new ParamEncoder(tableId).encodeParameterName(TableTagParameters.PARAMETER_SORT))To get the order (ASC/DESC):

获取排序request参数名字的措新葡的京集团350vip施为:

new ParamEncoder(tableId).encodeParameterName(TableTagParameters.PARAMETER_ORDER))Descending is 2, Ascending is 1.

降序为2,升序为1。

External Sorting And Paging (Partial Lists)

外部排序与分页(部分列表)

All of the above information for external sorting applies to partial lists. Additionally there are two new properties on the table tag: partialList and size. To enable partial lists simply set partialList="true" on the table tag. Next you must tell Display Tag the total size of your list since you are only making a specific subset of it available to the tag. You do this by storing the total list size in a java.lang.Integer object and putting it into some scope available to DisplayTag. Then you set size=(name the Integer was stored under) on the table tag. Very easy. It is also important that you specify a pagesize on the table tag. It is also a good idea to set your backend to load a default amount of your list when there are no request parameters, probably the first page worth of data.

上列展示了所有与部分列表外部排序有关的参数。留意,呈现了两个新的标签属性:partialList及size。应用部分列表只需简单的设定partialList="true"。接下来,既然你仅应用整个数据的子集,那么必须奉告标签数据列表的中数据的数量。奉告的措施便是,在DisplayTag可以造访到范围(sessionScope、request等),应用java.lang.Integer类型的工具来存储全部数据列表的数量,然后在标签中设定size即是上面存储数量时用的名字。异常轻易。新葡的京集团350vip表格标签设定pagesize参数也是很紧张的。当没有request参数的时刻,后台代码装载一个默认的列表数量是个好主见,可能......(这句没有搞懂是什么意思,原文为:probably the first page worth of data)。

To determine the starting record you need to return based on the request parameters provided via Display Tag you can do:

应用Display标签供给的request参数可以获得开始的记录,措施如下:

(Integer.parseInt(request.getParameter((new ParamEncoder(tableId).encodeParameterName(TableTagParameters.PARAMETER_PAGE)))) - 1) * pageSize.To get the ending record just add pageSize to the above value.

将上面的值加上pageSize就可以获得停止记录。

/奸淫奸淫奸淫**文章颁发请与本人联系,作者保留所有权利奸淫奸淫奸淫奸淫*/

作者:wallimn

电邮:wallimn@sohu.com

博客:http://blog.csdn.net/wallimn

收集硬盘:http://wallimn.ys168.com

免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。

您可能还会对下面的文章感兴趣: