[Seaside] Task Escape

Zulq Alam me at zulq.net
Wed Jan 9 19:27:05 UTC 2008

I have a task with N steps:

	self stepOne.
	self stepTwo.
	self stepN.

Each step calls one or more components. Each component offer a Cancel 
link / button. If clicked, the component answers false. If a component 
answers false, the task should stop. I currently do this by checking the 
answer value and then answering if the value is false.

	(self call: MyComponent new)
		ifFalse: [self answer: false]

This seems to work OK but only if the task has been called. If it is the 
root component, then the answer is a no-op.

I don't intend for such tasks to be used as root components and 
practically this isn't a problem but it doesn't feel right. The task 
should work no matter how it is being used.

I suppose I could check after each step (yuk):

	((self stepOne
		ifTrue: [self stepTwo])
			ifTrue: [self stepThree])
			ifTrue: [self stepN]

Or, I could check at the beginning of each step (*slightly* less yuk):

	shouldRun ifFalse: [^ self].


	self stepNMinusOne ifFalse: [^ self]

Or I could use a signal:

	(self call: MyComponent new) ifFalse: [MyCancellation signal]

	[self stepOne.
	self stepTwo.
	self stepThree]
		on: MyCancellation
		do: [self answer: false]

To me the signal looks the best, but feels like an abuse of the 
exception handling framework.

What have others done? It's very possible I still don't know how to use 
tasks properly, so please feel free to correct me!


More information about the seaside mailing list