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.
Get parent component in Seaside
131 Views Asked by Iyael At
3
There are 3 best solutions below
1
On
Iirc, the absence of a reference to a Component's parent was a conscious design decision. It is important for keeping components decoupled and self-contained. This is not to say that esteban's suggestion is wrong, we've also implemented something similar. You can do it, but it may have consequences like lingering references and hurdles to the reusability of components.
0
On
The normal way of dealing with this in Seaside is to connect the component loosely to its parent using announcements. The parent wires up its children to send it back an announcement.
See: this example
The short answer is that there is no simple way to do that.
The reason is that subclasses of
WAComponent(and alsoWAPresenter) 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
WAComponentsubclass, let's call itEAMComponentand this component has aparentinstance variable (and in my case, also amodelinstance variable).The
EAMComponent classimplementson: modelObject in: parentComponent(as well ason:andin: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:
Then in the footer component you can easily refer to the
parentthat is the object passed as argument to thein:part of the selector.