[Seaside] #call: #show: #home
Lukas Renggli
renggli at gmail.com
Tue Oct 11 03:19:48 UTC 2005
> I assume that #home should return you to the first component in a chain
> of called components. So component 1, calls component 2, calls component
> 3, and executing `self home` from component 3 should return you to
> component 1. Is that correct ?
No, #home removes all the delegation-decorations. This means if you
want to go back to component 1 you have to call home on component 1.
On component 3 it has no effect, after all it wouldn't know how far it
should go back in the chain of called-components, so call #home on the
component you want to show again.
> #show appears to be behaving exactly like #call. I assumed that show
> would replace the current component with the shown component but it
> appears to delegate. Turning on halos show this.
In most cases #show: works similar to #call:, but there is an
important difference: #call captures a continuation before actually
#show-ing the called component. This makes it possible to have a flow
of pages where you call each component and get the result.
a := self call: aFirstComp.
b := self call: aSecondComp.
c := self call: aThirdComp.
...
#show does not return a result (from #answer). However you can do
basically the same using continuation passing style with
#show:onAnswer:, but this is less natural and starts to become
complicated if you have flows with loops and conditions.
self show: aFirstComp onAnswer: [ :a |
self show: aSecondComp onAnswer: [ :b |
self show: aThirdComp onAnswer: [ :c |
... ] ] ]
I suggest that you always use #call:, it works as expected in all cases.
> Instead of calling and delegating to another component (presumably to
> wait for an answer) I would like to replace the current component with
> the called one. I could do this by putting my main navigation element
> outside of the called component but in this case it is not the most
> fitting approach.
Store a reference to the parent component in you child and do a call
on the parent, as you can see in WAParentTest.
HTH,
Lukas
--
Lukas Renggli
http://www.lukas-renggli.ch
More information about the Seaside
mailing list