[Seaside] Re: Finding the parent component of a rendered component

David Shaffer cdshaffer at acm.org
Tue Apr 24 16:55:10 UTC 2007

Luke wrote:
> Ok, maybe someone can help me figure out the logic I want here better than what
> I have figured out.
> I'm making a blog system.  I have the main application component as BlogView,
> and each post is rendered as a subcomponent BlogPostView.  Right now, I'm
> passing the BlogView object into each BlogPostView object so that if a
> BlogPostView's remove anchor is clicked, it verifies what they want to do, then
> removes it from the collection I'm using to store the posts, and tells the
> parent to re-generate it's list of children.
> What I want is a way to remove the need for the BlogPostView to have to know
> that a parent object even exists.  I want the BlogView to be able to generate a
> new set of children each time it is displayed, but if I do that right now, then
> any callbacks the children do are screwed up.  How do I get this parent view to
> generate a new list each time it is displayed, but not keep the callbacks in the
> children from working?
I'm not sure if this will work for you but one method I used in simple 
cases is an "onAnswer:" block in the children...toy example:

    super initialize.
    (child := Child new) onAnswer: [:answer | self updateList]

Child>>callbackWhenRemovePressed: theItem
    self removeTheItem: theItem.
    self answer: nil

This way you update your child list during a callback rather than on 
rendering so you should have fewer "callback not found" problems.


More information about the seaside mailing list