WARenderLoop


Seaside-RenderLoop

Comment:



Hierarchy:

ProtoObject
Object
WARenderLoop

Summary:

instance variables:

root

methods:

instance class
as yet unclassified call rendering no messages

Detail:

instance variables:

root
inferredType:
UndefinedObject

instance methods:

as yet unclassified
application

	^ self session application
basicRoot: aComponent

	root _ aComponent
root: aComponent

	self basicRoot: ((self application preferenceAt: #deploymentMode)
					ifFalse: [WAToolFrame on: aComponent]
					ifTrue: [aComponent])
session

	^ WACurrentSession value

call
call: aComponent

	^ self call: aComponent withToolFrame: true
call: aComponent withToolFrame: aBoolean

	aBoolean ifTrue: [self root: aComponent] ifFalse: [self basicRoot: aComponent].
	aComponent onAnswer: [:v | ^ v].
	self run

rendering
alwaysRedirect
	
	^ self application preferenceAt: #alwaysRedirect
processCallbacks: aCallbackStream

	| lastPosition |
	lastPosition _ nil.
	[aCallbackStream position = lastPosition] whileFalse:
		[lastPosition _ aCallbackStream position.
		root decorationChainDo: [:ea | ea processCallbackStream: aCallbackStream]].
	aCallbackStream atEnd
		ifTrue: [WARenderNotification raiseSignal]
		ifFalse: [self unprocessedCallbacks: aCallbackStream upToEnd].
redirect
	
	self alwaysRedirect ifTrue:
		[self session respond:
			[:url |
			self updateUrl: url.
			WAResponse redirectTo: url asString]]
render

	|request context document docRoot |
	
	context _ WARenderingContext new request: self session currentRequest.
	request _ self session respond:
				[:url | |response|
				self updateUrl: url.
				docRoot _ WARenderedHtmlRoot context: context.
				root visiblePresentersDo: [:ea | ea updateRoot: docRoot].
				self session application updateRoot: docRoot.				
				response _ WAResponse new.
				response headerAt: 'Cache-Control' put: 'No-cache'.
				document _ WAHtmlStreamDocument root: docRoot.
				document stream: response stream.
				context actionUrl: url; document: document.
				root decorationChainDo: [:ea | ea renderWithContext: context].				
				document close.
				response]. 

	self processCallbacks: (context callbackStreamForRequest: request)
run

	| notification |
	[self withPageExpiredHandler:
		[notification _ self withRenderNowHandler: [self render].
		 notification shouldRedirect ifTrue: [self redirect]]]
				repeat
unprocessedCallbacks: aCollection

	| owners |
	owners _ (aCollection collect: [:ea | ea owner]) asSet asArray.
	self error: 'Components not found while processing callbacks: ', owners asString
updateUrl: aUrl

	root visiblePresentersDo: [:c | c updateUrl: aUrl]
withPageExpiredHandler: aBlock

	^ aBlock on: WAPageExpired do: [:n |]
withRenderNowHandler: aBlock

	^ aBlock on: WARenderNotification do: [:n | n]

class methods:

^top


- made by Dandelion -