Package DE_EPAGES::Presentation::API::Object::Pager
Base class for pager objects.
Pagers are used for navigation in long lists.
Sub classes must override at least the 2 abstract methods
countItems and items.
see DE_EPAGES::Presentation::API::Object::PagerChildren
for an example implementation.
Base |
DE_EPAGES::Core::API::Object::BaseObject |
Example |
my $Pager = PagerClass->new({ PageSize => 10 }); $Pager->statistics; my $Count = $Pager->countItems; my $aItems = $Pager->items( 1 ); |
Functions
- allItems
- countItems
- countPages
- firstItemOfPage
- items
- lastItemOfPage
- new
- orderBy
- orderDesc
- page
- pageOfItem
- pageOfItemByObjectID
- sortObjects
- statistic
allItems
Returns all objects of all pages.
Syntax |
$aItems = $Pager->allItems; |
Return |
|
countItems
Returns the total number of items to be paged.
Syntax |
$Count = $Pager->countItems; |
Return |
|
countPages
Calculates the number of pages for a given number of items.
Syntax |
$CountPages = $Pager->countPages($CountOfItems); |
Input |
|
Return |
|
firstItemOfPage
Returns the 0-based index of the first item on a page.
Syntax |
$Index = $Pager->firstItemOfPage($Page); |
Input |
|
Return |
|
items
Returns all objects of a page.
Syntax |
$aItems = $Pager->items($Page); |
Input |
|
Return |
|
lastItemOfPage
Returns the 0-based index of the last item on a page.
Syntax |
$Index = $Pager->lastItemOfPage($Page); |
Input |
|
Return |
|
new
Creates a new pager object.
Syntax |
$Pager = DE_EPAGES::Presentation::API::Object::Pager->new($hInfo); |
Input |
|
Return |
|
orderBy
Returns the attribute by which the results are sorted.
Syntax |
$OrderBy = $Pager->orderBy; |
Return |
|
orderDesc
Returns the sort direction (ascending or descending).
Syntax |
$OrderDesc = $Pager->orderDesc; |
Return |
|
page
Returns the values that are required to display the current page. Runs $Pager->statistic if statistic wasnt run before. Calls $Pager->items($Page) for current page.
Syntax |
$hPagerVars = $Pager->page |
Example |
print $Pager->page->{'Pager'}->{'LastPage'}; # create a Pager from a UI (ViewAction) function sub ViewPagedChildren { my $self = shift; my $Servlet = shift; my $Pager = DE_EPAGES::Presentation::API::Object::PagerChildren->new({ 'Servlet' => $Servlet, 'Object' => $Servlet->object }); return $Pager->page; } |
Return |
|
pageOfItem
Returns the page where object with given objectid is positionate. Can used if pager doesnt contain real objects.
Syntax |
$Page = $Pager->pageOfItem(sub{ ... }); |
Example |
my $ObjectID = 0815; $Page = $Pager->pageOfItem(sub{ my ($Object) = @_; return $Object->id eq $ObjectID ? 1 : 0; }); |
Input |
|
Return |
|
pageOfItemByObjectID
Returns the page where object with given objectid is positionate. Can only used if pager contains real objects.
Syntax |
$Page = $Pager->pageOfItemByObjectID($ObjectID); |
Input |
|
Return |
|
sortObjects
Sorts the objects according to the 'OrderBy' and 'OrderDesc' attributes, which are set by corresponding input fields.
Syntax |
$aSortedObjects = $Pager->sortObjects($aObjects); |
Input |
|
Return |
|
statistic
Calls countPages and countItems to collect required information for all pages.
Syntax |
$Pager->statistic; |