WABatchedList


Seaside-Components-Widgets

Comment:



Hierarchy:

ProtoObject
Object
WAPresenter
WAComponent
WABatchedList

Summary:

instance variables:

batchSize currentPage items

methods:

instance class
accessing accessing-calculated actions initialization rendering testing as yet unclassified

Detail:

instance variables:

batchSize
currentPage
items

instance methods:

accessing
batchSize

	^ batchSize
batchSize: aNumber

	batchSize _ aNumber
currentPage

	^ currentPage
currentPage: aNumber

	currentPage _ aNumber
items

	^ items
items: aCollection

	items _ aCollection

accessing-calculated
batch

	^ items copyFrom: self startIndex to: self endIndex
endIndex

	^ currentPage * batchSize min: items size
maxPages

	^ (items size / batchSize) ceiling
pageRange

	^ self pageRangeStart to: self pageRangeEnd
pageRangeEnd

	^ self maxPages min: self currentPage + 9
pageRangeStart

	^ 1 max: self currentPage - 9
startIndex

	^ (currentPage - 1) * batchSize + 1

actions
nextPage

	self isOnLastPage ifFalse: [currentPage _ currentPage + 1]
previousPage

	self isOnFirstPage ifFalse: [currentPage _ currentPage - 1]

initialization
initialize

	batchSize _ 10.
	currentPage _ 1.
	self session registerObjectForBacktracking: self.

rendering
renderContentOn: html

	self maxPages > 0 ifTrue: [
		html divNamed: 'batch' with: [
			self renderPreviousOn: html.
			self renderPagesOn: html. 
			self renderNextOn: html ] ]
renderNextOn: html

	html space.
	self isOnLastPage
		ifFalse: [ html anchorWithAction: [ self nextPage ] text: '>>' ]
		ifTrue: [ html text: '>>' ]		
renderPagesOn: html

	self pageRange
		do: [ :index |
			currentPage = index
				ifFalse: [html anchorWithAction: [self currentPage: index] text: index]
				ifTrue: [html bold: index ] ]
		separatedBy: [ html space ]
renderPreviousOn: html

	self isOnFirstPage
		ifFalse: [ html anchorWithAction: [ self previousPage ] text: '<<' ]
		ifTrue: [ html text: '<<' ].
	html space.

testing
isOnFirstPage

	^ currentPage = 1
isOnLastPage

	^ currentPage = self maxPages

class methods:

as yet unclassified
example

	^self new
		items: (1 to: 100);
		yourself.
		

^top


- made by Dandelion -