PK >̀; ; build.batant -Dplay.path=D:\Programming\Projects\Personal\Utils\playPK ֈ>bmY build.xml
PK ֈ> commands.pyPK q?:.ԗ commands.pyc
TMc @ s d S( N( ( ( ( sG D:\Programming\Projects\Personal\Utils\PlayModules\paginate\commands.pyt s PK (NC@U% % manifestversion=head
frameworkVersions=1.x
PK V:@=W0 0 README.textileh1. paginate
paginate (http://github.com/lmcalpin/Play--Paginate) is a replacement for the standard #{list/} Play! tag.
h2. Getting Started
To include paginate in an existing project add the following lines to your **conf/application.conf** file
bc.
module.paginate=${play.path}/modules/paginate-head
h2. Using paginate
You can use paginate by creating an instance of a Paginator object. Two are provided for you, though you can always create your own:
**play.modules.paginate.ModelPaginator** is used to paginate standard Play! JPA-based models.
bc. public static void index() {
ModelPaginator paginator = new ModelPaginator(TheModel.class);
render(paginator);
}
You can also provide a JPA-QL WHERE clause and/or an ORDER clause to sort and filter the results.
bc. ModelPaginator entities = new ModelPaginator(Foo.class, "foo=?", "bar").orderBy("ID DESC"));
render(entities);
**play.modules.paginate.ValuePaginator ** is used to wrap any existing List.
bc. public static void index() {
List realList = ...;
ValuePaginator paginator = new ValuePaginator(realList);
render(paginator);
}
You can also simply provide a standard Java Collections API List, and behind the scenes, it will be autoboxed into a ValuePaginator.
bc. public static void index() {
List realList = ...;
render(realList);
}
From your view, include the pagination list and controls:
bc. #{paginate.list items:paginator, as:'r'}
... ${r} // or whatever
#{/paginate.list}
#{paginate.controls items:paginator /}
If you would like to use the default stylesheet, include this somewhere in your layout:
bc.
If you would like to include a summary "Displaying rows X to Y", you may include the
summary tag:
bc. #{paginate.summary items:paginator/}
You can use the standard Play! #{else} tag with #{paginate.list}.
The contents within this tag will be rendered if the collection is empty:
bc. #{paginate.list items:emptyCollection, as:'doesntmatter'}
This content won't be displayed
#{/paginate.list}
#{else}
Empty list!
#{/else}
h2. Customization
Pagination controls are controlled by the view paginate/Controls.html and can be overridden in your project.
The following properties are available to customize pagination display:
- get/setBoundaryControlsEnabled: determines whether the First and Last buttons are displayed
- get/setPagesDisplayed: customizes the number of pages that show up between the forward/backward controls
- get/setPageSize: determines the number of rows we display per page
*Request Parameters*
By default, paginator uses the "page" request parameter to determine what page you are viewing. If you would
like to override that, you can add a "paginator.parameter.name" entry to your application.conf:
paginator.parameter.name=__pagenumber
However, using the default page request parameter will paginate every single pagination control on the page.
To avoid that, you need to invoke the setParameterName() method in your controller.
ModelPaginator entities = new ModelPaginator(...);
entities.setParameterName("foo");
render(entities);
The example above will use the request parameter "foo" to capture the current page number for the ModelPaginator
associated with the variable named "entities."
There is currently no way to change the parameter name used for Lists that are autoboxed into ValuePaginators.
*Query Cache*
The JPA paginators try to use Hibernate's query cache, if you have one configured. You can disable this by
adding "paginator.jpa.useQueryCache=false" to your application.conf.
h2. Row Count Summary
An additional summary tag is available if you would like to display the message: "Displaying rows X to Y
out of Z records."
#{paginate.summary items:paginator /}
h2. Version History
0.1 - 7/26/2011
- initial versioned release
0.11 - 9/13/2011
- minor bug fixes
0.12 11/23/2011
- add support for Sets and Maps
- add multidb support
- support entities with non-default naming (@Entity(name="..."))
- use query cache if available
- bug fix: eliminate duplicate row count checks
0.13 1/26/2012
- bug fix: css class of last control was incorrect (thanks @peteyhawkins)
- bug fix: else tag incorrectly displayed for non-empty lists if an if statement preceding the list is not satisfied (thanks @marioosh)
- support entities extending GenericModel
PK V:@ app/views/paginate/Controls.html%{
int __firstPage = 1;
int __currentPage = _items.pageNumber;
int __pagesDisplayed = _items.pagesDisplayed;
int __pagesBeforeMiddle = __pagesDisplayed / 2;
int __maxPage = _items.pageCount;
if (__currentPage > (__pagesDisplayed / 2)) {
__firstPage = __currentPage - __pagesBeforeMiddle;
}
int __lastPage = __currentPage + (__pagesDisplayed - __pagesBeforeMiddle - 1);
if (__currentPage < (__pagesDisplayed - __pagesBeforeMiddle)) {
__lastPage = __pagesDisplayed;
}
if (__lastPage > __maxPage) {
__lastPage = __maxPage;
}
boolean __hasPrev = _items.hasPreviousPage;
boolean __hasNext = _items.hasNextPage;
String __firstURL = __hasPrev ? _items.getCallbackURL(1) : "#";
String __prevURL = __hasPrev ? _items.getCallbackURL(__currentPage-1) : "#";
String __nextURL = __hasNext ? _items.getCallbackURL(__currentPage+1) : "#";
String __lastURL = __hasNext ? _items.getCallbackURL(__maxPage) : "#";
%}
PK ֈ>Gu ' app/views/paginate/RowCountSummary.html&{'play-paginate.summary.display'} ${_items.firstRowIndex + 1} &{'play-paginate.summary.to'} ${_items.lastRowIndex + 1} &{'play-paginate.summary.from'} ${_items.rowCount} &{'play-paginate.summary.entries'}
PK > % app/views/tags/paginate/controls.html%{
if (_items != null) {
// wrap raw Lists with the Paginator class
if (_items instanceof List && !(_items instanceof play.modules.paginate.Paginator)) {
_items = new play.modules.paginate.ValuePaginator(_items);
}
}%
#{include 'paginate/Controls.html'/}
%{
}
}%
PK V:@P?p p ! app/views/tags/paginate/list.html%{
if (_items != null) {
// wrap raw Lists with the Paginator class
if (!(_items instanceof play.modules.paginate.Paginator)) {
if (_items instanceof List || _items instanceof Set || _items instanceof Map) {
_items = new play.modules.paginate.ValuePaginator(_items);
}
}
idx = _items.firstRowIndex + 1;
rowCount = _items.rowCount;
for (_r in _items.currentPage) {
layoutData = nil;
if (play.version.startsWith("1.0")) {
layoutData = play.templates.Template.layoutData.get();
} else { // play 1.1 (and hopefully later?)
layoutData = play.templates.BaseTemplate.layoutData.get();
}
layoutData.put(_as, _r);
layoutData.put(_as+'_index', idx);
layoutData.put(_as+'_isLast', idx == rowCount);
layoutData.put(_as+'_isFirst', idx == 1);
layoutData.put(_as+'_parity', idx % 2 == 0 ? 'even' : 'odd');
idx++;
%}
#{doBody/}
%{
}
if (rowCount == 0) {
play.templates.TagContext.parent().data.put('_executeNextElse', true);
}else{
play.templates.TagContext.parent().data.put('_executeNextElse', false);
}
}
%}
PK > * * $ app/views/tags/paginate/summary.html%{
if (_items != null) {
// wrap raw Lists with the Paginator class
if (_items instanceof List && !(_items instanceof play.modules.paginate.Paginator)) {
_items = new play.modules.paginate.ValuePaginator(_items);
}
%}
#{include 'paginate/RowCountSummary.html' /}
%{
}
}%
PK ֈ>p
conf/messages# Default play-paginate messages
# You can specialize this file for each language.
# For exemple, for french create a messages.fr file
#play-paginate.name=play-paginate
play-paginate.first=« First
play-paginate.prev=‹ Previous
play-paginate.next=Next ›
play-paginate.last=Last »
play-paginate.summary.display=Displaying rows
play-paginate.summary.to=to
play-paginate.summary.from=out of
play-paginate.summary.entries=entries
PK ֈ>F F conf/messages.frplay-paginate.first=« Premier
play-paginate.prev=‹ Précédent
play-paginate.next=Suivant ›
play-paginate.last=Dernier »
play-paginate.summary.display=Affichage des lignes
play-paginate.summary.to=à
play-paginate.summary.from=de
play-paginate.summary.entries=entrées
PK ֈ>~" conf/routes# This file defines all module routes (Higher priority routes first)
#
# import these routes in the main app as :
# * / module:play-paginate
#
# ~~~~
GET /? Module.indexPK Kw?^T ! documentation/manual/home.textileh1. paginate
paginate (http://github.com/lmcalpin/Play--Paginate) is a replacement for the standard #{list/} Play! tag.
h2. Getting Started
To include paginate in an existing project add the following lines to your **conf/application.conf** file
bc.
module.paginate=${play.path}/modules/paginate-head
h2. Using paginate
You can use paginate by creating an instance of a Paginator object. Two are provided for you, though you can always create your own:
**play.modules.paginate.ModelPaginator** is used to paginate standard Play! JPA-based models.
bc. public static void index() {
ModelPaginator paginator = new ModelPaginator(TheModel.class);
render(paginator);
}
You can also provide a JPA-QL WHERE clause and/or an ORDER clause to sort and filter the results.
bc. ModelPaginator entities = new ModelPaginator(Foo.class, "foo=?", "bar").orderBy("ID DESC"));
render(entities);
**play.modules.paginate.ValuePaginator ** is used to wrap any existing List.
bc. public static void index() {
List realList = ...;
ValuePaginator paginator = new ValuePaginator(realList);
render(paginator);
}
You can also simply provide a standard Java Collections API List, and behind the scenes, it will be autoboxed into a ValuePaginator.
bc. public static void index() {
List realList = ...;
render(realList);
}
From your view, include the pagination list and controls:
bc. #{paginate.list items:paginator, as:'r'}
... ${r} // or whatever
#{/paginate.list}
#{paginate.controls items:paginator /}
If you would like to use the default stylesheet, include this somewhere in your layout:
bc.
If you would like to include a summary "Displaying rows X to Y", you may include the
summary tag:
bc. #{paginate.summary items:paginator/}
You can use the standard Play! #{else} tag with #{paginate.list}.
The contents within this tag will be rendered if the collection is empty:
bc. #{paginate.list items:emptyCollection, as:'doesntmatter'}
This content won't be displayed
#{/paginate.list}
#{else}
Empty list!
#{/else}
h2. Customization
Pagination controls are controlled by the view paginate/Controls.html and can be overridden in your project.
The following properties are available to customize pagination display:
- get/setBoundaryControlsEnabled: determines whether the First and Last buttons are displayed
- get/setPagesDisplayed: customizes the number of pages that show up between the forward/backward controls
- get/setPageSize: determines the number of rows we display per page
*Request Parameters*
By default, paginator uses the "page" request parameter to determine what page you are viewing. If you would
like to override that, you can add a "paginator.parameter.name" entry to your application.conf:
paginator.parameter.name=__pagenumber
However, using the default page request parameter will paginate every single pagination control on the page.
To avoid that, you need to invoke the setParameterName() method in your controller.
ModelPaginator entities = new ModelPaginator(...);
entities.setParameterName("foo");
render(entities);
The example above will use the request parameter "foo" to capture the current page number for the ModelPaginator
associated with the variable named "entities."
There is currently no way to change the parameter name used for Lists that are autoboxed into ValuePaginators.
*Query Cache*
The JPA paginators try to use Hibernate's query cache, if you have one configured. You can disable this by
adding "paginator.jpa.useQueryCache=false" to your application.conf.
h2. Row Count Summary
An additional summary tag is available if you would like to display the message: "Displaying rows X to Y
out of Z records."
#{paginate.summary items:paginator /}
PK &z?$1 1 ' eclipse/Connect JPDA to unittest.launch
PK &z?ez z eclipse/Test unittest.launch
PK &z?5>2 2 eclipse/unittest.launch
PK ֈ> eclipse/classes/play.pluginsPK KC@1V 8 eclipse/classes/play/modules/paginate/JPAPaginator.class 2 G "play/modules/paginate/JPAPaginator play/modules/paginate/Paginator java/io/Serializable serialVersionUID J
ConstantValueYrꜵg $(Ljava/lang/Class;Ljava/util/List;)V Signature .(Ljava/lang/Class;Ljava/util/List;)V Code 7play/modules/paginate/strategy/JPARecordLocatorStrategy
9(Lplay/modules/paginate/strategy/RecordLocatorStrategy;)V LineNumberTable LocalVariableTable this $Lplay/modules/paginate/JPAPaginator; typeToken Ljava/lang/Class; keys Ljava/util/List; LocalVariableTypeTable ,Lplay/modules/paginate/JPAPaginator; Ljava/lang/Class; Ljava/util/List; (Ljava/lang/Class;)V (Ljava/lang/Class;)V
' $ 9(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Object;)V >(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Object;)V
+ ( filter Ljava/lang/String; params [Ljava/lang/Object; orderBy 8(Ljava/lang/String;)Lplay/modules/paginate/JPAPaginator; @(Ljava/lang/String;)Lplay/modules/paginate/JPAPaginator;
4 5 6 jpaStrategy ;()Lplay/modules/paginate/strategy/JPARecordLocatorStrategy;
8 9 :
setOrderBy (Ljava/lang/String;)V
orderByClause
= > ? getRecordLocatorStrategy 8()Lplay/modules/paginate/strategy/RecordLocatorStrategy; withKeyNamed
B @ : key
SourceFile JPAPaginator.java iLplay/modules/paginate/Paginator;Ljava/io/Serializable; !
v * Y+,
'
( ! " # $ % a
* Y+ &