dw.web
Class PagingModel
dw.web.PagingModel
A page model is a helper class to apply a pages to a collection of
elements or an iterator of elements and supports creating URLs for
continued paging through the elements.
The page model is intended to be initialized with the collection or
iterator, than the paging position is applyed and than the elements are
extracted with getPageElements().
In case the page model is initialized with a collection the page model
can be reused multiple times.
Constants
DEFAULT_PAGE_SIZE
:
Number = 10
The default page size.
MAX_PAGE_SIZE
:
Number = 2000
The maximum supported page size.
PAGING_SIZE_PARAMETER
:
String = "sz"
The URL Parameter used for the page size.
PAGING_START_PARAMETER
:
String = "start"
The URL parameter used for the start position.
Properties
count
:
Number
(Read Only)
The count of the number of items in the model.
currentPage
:
Number
(Read Only)
The index number of the current page. The page
counting starts with 0. The method also works with a miss-aligned
start. In that case the start is always treated as the start of
a page.
end
:
Number
(Read Only)
The index of the last element on the current page.
maxPage
:
Number
(Read Only)
The maximum possible page number. Counting for pages starts
with 0. The method also works with a miss-aligned start. In that case
the returned number might be higher than ((count-1) / pageSize).
pageCount
:
Number
(Read Only)
The total page count. The method also works
with a miss-aligned start. In that case the returned number might
be higher than (count / pageSize).
pageElements
:
Iterator
(Read Only)
An iterator that can be used to iterate through the elements of
the current page.
In case of a collection as the page models source, the method can be
called multiple times. Each time a fresh iterator is returned.
In case of an iterator as the page models source, the method must be
called only once. The method will always return the same iterator,
which means the method amy return an exhausted iterator.
pageSize
:
Number
The size of the page.
start
:
Number
The current start position from which iteration will start.
Constructor Summary
PagingModel(elements
:
Iterator, count
:
Number)
Constructs the PagingModel using the specified iterator and count value.
PagingModel(elements
:
Collection)
Constructs the PagingModel using the specified collection.
Method Summary
static appendPageSize(url
:
URL, pageSize
:
Number)
:
URL
Returns an URL containing the page size parameter appended to the specified url.
appendPaging(url
:
URL)
:
URL
Returns an URL by appending the current page start position and the current page size to the URL.
appendPaging(url
:
URL, position
:
Number)
:
URL
Returns an URL by appending the paging parameters for a desired page start position and the current page size to the specified url.
getCurrentPage()
:
Number
Returns the index number of the current page.
getMaxPage()
:
Number
Returns the maximum possible page number.
getPageCount()
:
Number
Returns the total page count.
getPageElements()
:
Iterator
Returns an iterator that can be used to iterate through the elements of the current page.
getPageSize()
:
Number
Returns the size of the page.
isEmpty()
:
boolean
Identifies if the model is empty.
setPageSize(pageSize
:
Number)
:
void
Sets the size of the page.
Methods inherited from class
Object
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
Constructor Detail
PagingModel
Constructs the PagingModel using the specified iterator and count value.
Count must not be negative.
Note: A valid count must be provided. The PageModel class can not be used
if the number of elements is unknown. Without knowning the number of
elements it still would be possible to return the elements of a particular
page, but it would be not possible to calculate data like the total number
of pages or to construct an URL to jump to a particular page.
Parameters:
elements
-
the iterator containing the model elements.
count
-
the count of elements.
PagingModel
public PagingModel(elements
:
Collection)
Constructs the PagingModel using the specified collection.
Parameters:
elements
-
the collection containing the model elements.
Method Detail
appendPageSize
Returns an URL containing the page size parameter appended to the
specified url. The name of the page size parameter is 'sz' (see
PAGE_SIZE_PARAMETER). The start position parameter is not appended to the
returned URL.
Parameters:
url
-
the URL to append the page size parameter to.
pageSize
-
the page size
Returns:
an URL that contains the page size parameter.
appendPaging
Returns an URL by appending the current page start position and the
current page size to the URL.
Parameters:
url
-
the URL to append the current paging position to.
Returns:
an URL containing the current paging position.
appendPaging
Returns an URL by appending the paging parameters for a desired
page start position and the current page size to the specified url. The name of
the page start position parameter is 'start' (see PAGING_START_PARAMETER)
and the page size parameter is 'sz' (see PAGE_SIZE_PARAMETER).
Parameters:
url
-
the URL to append the paging parameter to.
position
-
the start position.
Returns:
an URL that contains the paging parameters.
getCount
getCount()
:
Number
Returns the count of the number of items in the model.
Returns:
the count of the number of items in the model.
getCurrentPage
getCurrentPage()
:
Number
Returns the index number of the current page. The page
counting starts with 0. The method also works with a miss-aligned
start. In that case the start is always treated as the start of
a page.
Returns:
the index number of the current page.
getEnd
getEnd()
:
Number
Returns the index of the last element on the current page.
Returns:
the index of the last element on the current page.
getMaxPage
getMaxPage()
:
Number
Returns the maximum possible page number. Counting for pages starts
with 0. The method also works with a miss-aligned start. In that case
the returned number might be higher than ((count-1) / pageSize).
Returns:
the maximum possible page number.
getPageCount
getPageCount()
:
Number
Returns the total page count. The method also works
with a miss-aligned start. In that case the returned number might
be higher than (count / pageSize).
Returns:
the total page count.
getPageElements
getPageElements()
:
Iterator
Returns an iterator that can be used to iterate through the elements of
the current page.
In case of a collection as the page models source, the method can be
called multiple times. Each time a fresh iterator is returned.
In case of an iterator as the page models source, the method must be
called only once. The method will always return the same iterator,
which means the method amy return an exhausted iterator.
Returns:
an iterator that you use to iterate through the elements of the current page.
getStart
getStart()
:
Number
Returns the current start position from which iteration will start.
Returns:
the current start position from which iteration will start.
isEmpty
isEmpty()
:
boolean
Identifies if the model is empty.
Returns:
true if the model is empty, false otherwise.
setPageSize
setPageSize(pageSize
:
Number)
:
void
Sets the size of the page. The page size must be greater or
equal to 1.
Parameters:
pageSize
-
the size of the page.
setStart
setStart(start
:
Number)
:
void
Sets the current start position from which iteration will start.
Parameters:
start
-
the current start position from which iteration will start.
© Copyright 2000-2024, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners.