[Seaside] Seaside + Scriptaculous: Question on SUAjax onLoad, onComplete, etc.

Leandro Pérez lperez at lifia.info.unlp.edu.ar
Wed Jun 27 19:10:10 UTC 2007

First of all, thanks a lot Lukas and Niklaus!!!

Niklaus Lutz wrote:
> hy
> Maybe I've done something similar some time ago: After a file-upload,
> the file had to be processed, that took up to several minutes....
> My Solution:
> In the callback of the upload button i forked a new thread that
> processed the file:
> #import
>  [
> self threadRunning: true.
>   self processFile.
> self threadRunning: false.
> ]   forkAt: Processor userBackgroundPriority named: 'Monitor import'
> Render some information (duration) while the import is running, during
> this time poll to see if the thread has finished:
> #renderProgressBarOn: html
> 	html div
> 		id: 'divProgressbar';
> 		with: [
> 			html text: #pleaseWaitTillImportHasFinished translate ] .
> #renderValidationOn: html
> 	self renderProgressBarOn: html.
> 	html div
> 		script: (
>                     html periodical
> 			evalScripts: true;
> 			frequency: 1;
> 			callback: [ :r |
> 				self isThreadRunning:
> 					ifFalse: [
> 						r script:'updater.stop();$('divProgressbar'').setStyle({display:
> ''none''});'.
> 						super  renderValidationOn: r ]
> 					ifTrue: [
> 						r render: self elapsedTime duration ]];
> 			assignTo: 'updater');
> 		with: [ ].
> so instead of hiding the progress-bar, you could do another
> full-request....
I did basically what you say here, besides I used a high decay as stated in
a post by Ramon Leon on Ajax Live Updates and other..


It is working fine, but another problem came up now, it is something i
simply don't understand. Please 
Look at the code below, at the part "LOOK HERE PLEASE!!!"

html div id:'div' with:'some content'.
(html submitButton)
	onClick: (html evaluator callback: [:script | 
		[(Delay forSeconds:10)"Simulate long running process".
		self setWorkFinished] fork
		self update: 'div'
		whenTrue: [self isWorkFinished]
		rendering: [:h |  h submitButton  "this works fine" 
                                      "h checkbox....when doing this, poll
doesn't stop"]"LOOK HERE PLEASE!!!"
		on: script]);
	text: 'Spin'.

MyComponent>>update: elementId whenTrue: aBlock rendering: renderBlock on:
	(script element)
	id: elementId;
	render:[:r | r div 
		     with: [:h | renderBlock value: h]
		     waitForCondition: aBlock
		     thenRender: [:h  | renderBlock value: h]]
WATagBrush >> with: initialRenderBlock waitForCondition: aBlock thenRender:
	    script: ((canvas periodical)
		  id: (self attributes at: #id);
		  decay: 1000;
		  asynchronous: true;
		  evalScripts: true;
		  frequency: 1 seconds;
			[:r | 
			aBlock value 
			    ifFalse:[initialRenderBlock value: r.
				     r hiddenInput text: r nextId    "This is to keep decay
low...generates different responses"]
			    ifTrue: [aRenderBlock value: r]]);
	    with: initialRenderBlock

If in the line "LOOK HERE PLEASE!!!" I render an anchor, simple text, a
submit button, a textInput etc.. it works just fine and nothing weird
happens, but If I try to render a checkbox, a non-stopping poll mechanism
starts and I end up with a post every 1 second. 
It is weird because it only happens when I render a checkbox

any ideas????
View this message in context: http://www.nabble.com/Seaside-%2B-Scriptaculous%3A-Question-on-SUAjax-onLoad%2C-onComplete%2C-etc.-tf3984652.html#a11330698
Sent from the Squeak - Seaside mailing list archive at Nabble.com.

More information about the Seaside mailing list