All pastes #44557 Raw Edit

seaside liveupdate

public text v1 · immutable
#44557 ·published 2006-03-05 15:24 UTC
rendered paste body
WACallback add instvar 'request'

WACallback>>evaluateWithField: anObject request: aRequest
	request := aRequest.
	self evaluateWithArgument: (self valueForField: anObject)


WACallbackStream>>processCallbacksWithOwner: anObject
	| callback |
	[callbacks atEnd not and: [callbacks peek owner == anObject]] whileTrue:
		[callback := callbacks next.
		callback evaluateWithField: (request fields at: callback key) request: request]

WAActionCallback subclass: #WALiveActionCallback
	instanceVariableNames: 'callbacks'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Seaside-Rendering'

WAActionCallback>>callbacks
	^callbacks
	
WAActionCallback>>callbacks: anObject
	callbacks := anObject
	
WAActionCallback>>evaluateWithArgument: argument 
	| innerContext response renderer document |
	innerContext := context copy.
	response := WAResponse new.
	response contentType: 'text/xml'.
	renderer := WAHtmlRenderer
					context: innerContext
					callbacks: self callbacks.
	document := WAHtmlStreamDocument new stream: response stream.
	renderer context document: document.
	block value: (request at: 's' ifAbsent: []) value: renderer.
	document close.
	WACurrentSession value returnResponse: response


WACallbackRegistry>>registerLiveActionCallback: aBlock 
	^self storeCallback: (WALiveActionCallback new block: aBlock; callbacks: self)


WAHtmlRenderer>>urlForLiveAction: actionBlock 
	| url |
	url := context actionUrl 
				withParameter: (self callbacks registerLiveActionCallback: actionBlock).
	^url asString


^^^^ use this in live update methods instead of #urlForLiveRequest: