[Seaside] Displaying progress on a web page
breedt_m at aircom.co.za
Thu Aug 24 08:32:25 UTC 2006
Thank you very much for your example. It was of great help. I used your
tip about the hidden input with the unique id and the high decay rate
and it worked great!
From: Ramon Leon [mailto:ramon.leon at allresnet.com]
Sent: 17 Augustus 2006 05:49 nm
To: 'The Squeak Enterprise Aubergines Server - general discussion.'
Subject: RE: [Seaside] Displaying progress on a web page
> -----Original Message-----
> From: seaside-bounces at lists.squeakfoundation.org
> [mailto:seaside-bounces at lists.squeakfoundation.org] On Behalf
> Of Mart-Mari Breedt
> Sent: Thursday, August 17, 2006 4:38 AM
> To: The Squeak Enterprise Aubergines Server - general discussion.
> Subject: RE: [Seaside] Displaying progress on a web page
> Thanks Philippe,
> I think fixing Comet is a little bit much for a relative
> newbie like myself to chew on :-), but I did try the
> periodical updates and I got the effect I desired. Was just
> wondering if there was another way to do this...
> About the script redirecting to the next page, do you maybe
> have an example of such a script? Or is there a way to stop
> the updates? I have this scenario now where the update just
> keeps on running even after no progress has been made on the
> client side.
> Thank you,
Try this, on your periodical, set a high decay rate, say 1000. This
stop the polling if the same answer comes back twice. Then in the
method, besides what you're already rendering, do something like this...
r hiddenInput text: r nextId
This will make each answer unique preventing the decay from kicking in.
When you want to stop polling, stop rendering the hidden value, and
will stop after the next hit.
I've added a couple small extension methods to WATagBrush that I have
publish, but they seem to be working pretty well for me so far. I use
polling to fork off a long running process on another thread, then poll
the result until it finishes or times out. No promises, but I'll share
I use for now.
WATagBrush>>with: initialBlock waitMax: aDuration forWork: aBlock
self attributeAt: #default put: initialBlock value.
self with: initialBlock.
self waitMax: aDuration forWork: aBlock thenRender: aRenderBlock
WATagBrush>>waitMax: aDuration forWork: aBlock thenRender: aRenderBlock
"poll for results, stop when found or timeout expires"
| result |
result := self forkWaitFor: aDuration longRunningProcess: aBlock.
canvas script: ((canvas periodical)
id: (self attributes at: #id);
(result at: #result) ifNil:
[r text: (self attributeAt: #default).
r hiddenInput text: r nextId]
ifNotNil: [aRenderBlock value: r value:
WATagBrush>>forkWaitFor: aDuration longRunningProcess: aBlock
| startAt result |
result := (Dictionary new)
at: #result put: nil;
startAt := DateAndTime now.
[[[(result at: #result) isNil] whileTrue:
[DateAndTime now - startAt > aDuration ifTrue: [Error
(Delay forMilliseconds: 100) wait.
result at: #result put: aBlock value]]
do: [:error | result at: #result put: error messageText]]
forkNamed: 'ajax async:'.
I use it like so...
with:[html text: 'Searching...']
waitMax: 30 seconds
forWork: [self getDataFromLongRunningProcess]
thenRender:[:r :value | r text: value]
Seaside mailing list
Seaside at lists.squeakfoundation.org
More information about the Seaside