[Seaside] How to stop periodical, end a polling mechanism... again

Leandro Pérez lperez at lifia.info.unlp.edu.ar
Wed Jul 11 19:13:16 UTC 2007


Ok, I've just pinpointed what my problem was, I'll try to explain what i've
found, but I have to say that I don't completely understand what is going on
or why.. so, if anyone can explain the reasons it would be very nice!

The next few lines work ok, 

renderContentOn: html 

html div id: 'myDiv'.
	(html submitButton)
		id: 'button';
		onClick: (html evaluator callback: 
						[:script | 
						
						[working:= true.
						(Delay forSeconds: 5) wait. "simulate the long running process"
						working:= false] 
								fork]);
		onClick: ((html periodical)
					id: 'myDiv';
					frequency: 1 second;
					assignTo: 'periodical';
					callback: 
							[:r | 
							working
								ifFalse: 
									[r script: ((r element)
												alias: 'periodical';
												call: 'stop')]]);
		text: 'Work!'


This renders a submit button that, when clicked, triggers a long running
process server side, and a periodical updater client side. The idea is that
the periodical will poll to the server every 1 second until the long running
process is finished, then, a script is rendered that stops the client side
periodical updater. This could be used to display a work in progress image
or something like that..

My problem was that I wasn't giving an id to the periodical, or that such id
didn't match any other element's id. In any case, the periodical polled
forever..

Example n.1: this example bellow does not work as it is meant to. The
periodical never stops polling...

renderContentOn: html 

       "Note that the div with id=myDiv is missing here!"

	(html submitButton)
		id: 'button';
		onClick: (html evaluator callback: 
						[:script | 
						
						[working:= true.
						(Delay forSeconds: 5) wait. "simulate the long running process"
						working:= false] 
								fork]);
		onClick: ((html periodical)
					id: 'myDiv';
					frequency: 1 second;
					assignTo: 'periodical';
					callback: 
							[:r | 
							working
								ifFalse: 
									[r script: ((r element)
												alias: 'periodical';
												call: 'stop')]]);
		text: 'Work!'

Could it be because the rendered script is not associated to any element???
no idea


Example n.2: no id is given to the periodical, it does not work either.

renderContentOn: html 

      html div id: 'myDiv'.
	(html submitButton)
		id: 'button';
		onClick: (html evaluator callback: 
						[:script | 
						
						[working:= true.
						(Delay forSeconds: 5) wait. "simulate the long running process"
						working:= false] 
								fork]);
		onClick: ((html periodical)
					"This line is a comment id: 'myDiv';"
					frequency: 1 second;
					assignTo: 'periodical';
					callback: 
							[:r | 
							working
								ifFalse: 
									[r script: ((r element)
												alias: 'periodical';
												call: 'stop')]]);
		text: 'Work!'

The results here are even stranger, the periodical stops polling but inside
the submit button some sort of a nested input field is rendered (at least in
firefox).. very weird..

Well, I hope anyone has some answers to clarify my mind, and that this will
be usefull to somebody
Regards
Leandro
---
VisualWorks nc.7.5
Seaside (2.8a1.399)
SeasideScriptaculous (2.8a1.205.0,mbany)

-- 
View this message in context: http://www.nabble.com/How-to-stop-periodical%2C-end-a-polling-mechanism...-again-tf4030323.html#a11546984
Sent from the Squeak - Seaside mailing list archive at Nabble.com.



More information about the Seaside mailing list