I wanted to see if there is any possibility in Seaside that a child component gets the reference to the parent component, without using the session or parameter passage. That is, the child component making, for example, a call to self gets the parent component.
The short answer is that there is no simple way to do that.
The reason is that subclasses of WAComponent
(and also WAPresenter
) have no direct reference to a parent component, since for rendering purposes this is not needed, because the visitor performs a top-down path and depending on a parent element introduces a coupling of some sort, and an instance variable that might not be used.
To overcome that, I have my own WAComponent
subclass, let's call it EAMComponent
and this component has a parent
instance variable (and in my case, also a model
instance variable).
The EAMComponent class
implements on: modelObject in: parentComponent
(as well as on:
and in:
that depend on the former, influenced by Dolphin's implementation of Model-View-Presenter).
So then on the parent component the resulting idiom is something like:
createChildrenComponents
dateComponent := EAMTextComponent on: self date in: self.
footerComponent := EAMFooterComponent in: self.
Then in the footer component you can easily refer to the parent
that is the object passed as argument to the in:
part of the selector.