| request handling |
| actionField
|
^ '_k'
|
| currentRequest
|
^ currentRequest
|
| errorHandler
|
^ application preferenceAt: #errorHandler
|
| incomingRequest: aRequest
|
((aRequest fields includesKey: 'terminate')
and: [(self application preferenceAt: #deploymentMode) not])
ifTrue: [monitor terminate. ^ WAResponse new nextPutAll: 'Process terminated'].
^ monitor
critical: [self responseForRequest: aRequest]
ifError: [:e | WAResponse internalError: e]
|
| performRequest: aRequest
|
| key continuation |
key _ aRequest fields at: self actionField ifAbsent: [^ self start: aRequest].
continuation _ continuations at: key ifAbsent: [^ self unknownRequest: aRequest].
continuation value: aRequest
|
| responseForRequest: aRequest
|
currentRequest _ aRequest.
^ self withEscapeContinuation:
[WACurrentSession use: self during: [self withErrorHandler: [self performRequest: aRequest]]]
|
| start: aRequest
|
self mainClass new start: aRequest
|
| unknownRequest: aRequest
|
self pageExpired
|
| withErrorHandler: aBlock
|
^ [aBlock
on: Error
do: [:e | self errorHandler handleError: e. WAPageExpired raiseSignal]]
on: Warning
do: [:w | self errorHandler handleWarning: w. WAPageExpired raiseSignal]
|
| withEscapeContinuation: aBlock
|
^ EscapeContinuation currentDo:
[:cc |
escapeContinuation := cc.
aBlock value.
self pageIntentionallyLeftBlank]
|
| responding |
| actionUrlForContinuation: aContinuation
|
^ self actionUrlForKey: (continuations store: aContinuation)
|
| actionUrlForKey: aString
|
^ (application urlForRequestHandler: self)
addParameter: self actionField value: aString;
yourself
|
| closePopup
|
^ self respond:
[:url |
WAResponse new
nextPutAll: '<html><script>';
nextPutAll: 'self.close();';
nextPutAll: 'self.opener.location=self.opener.location';
nextPutAll: '</script></html>';
yourself]
|
| closePopupAndContinue
|
^ self respond:
[:url |
WAResponse new
nextPutAll: '<html><script>';
nextPutAll: 'self.close();';
nextPutAll: 'self.opener.location=',url asString printString;
nextPutAll: '</script></html>';
yourself]
|
| pageIntentionallyLeftBlank
|
self returnResponse: WAResponse new
|
| redirect
|
^ self respond: [:url | WAResponse redirectTo: url asString]
|
| redirectTo: urlString
|
self returnResponse: (WAResponse redirectTo: urlString)
|
| redirectWithMessage: aString delay: aNumber
|
self respond:
[:url |
WAResponse
refreshWithMessage: aString
location: url asString
delay: aNumber].
|
| respond: responseBlock
|
|request snapshotHolder response oldEscape |
snapshotHolder _ ValueHolder new.
oldEscape _ escapeContinuation.
escapeContinuation _
[:v |
snapshotHolder contents: state snapshot.
oldEscape value: v].
request _
ResponseContinuation currentDo:
[:cc ||url|
url _ self actionUrlForContinuation: cc.
response _ responseBlock value: url.
self returnResponse: response].
state restoreSnapshot: snapshotHolder contents.
^ request
|
| returnResponse: aResponse
|
escapeContinuation value: aResponse
|
| script: aString
|
self redirectWithMessage: '<script>', aString, '</script>' delay: 0
|