[Seaside] Setting instance variables

Avi Bryant avi@beta4.com
Thu, 6 Jun 2002 01:01:31 -0700 (PDT)


On Thu, 6 Jun 2002, Jim Benson wrote:

> Hmm,
>
> This approach doesn't seem very MVC to me.
>
> I view the top page as the model, I'm not sure in general that I want to
> keep track of things in the main component in order to properly  initialize
> subcomponents.

I agree, it's not great (but actually it isn't/won't be a problem with
0.94, see below).  Honestly, I've never run into that particular issue
before - generally, if the parent is providing data to the subcomponents,
it wants to keep track of how that data's changing or be able to modify it
later.

In general, the management of state (shared and not shared) between
parents and subcomponents is the trickiest issue, by far, of the
framework.  This becomes particularly apparent when you do things like put
subcomponents inside a repeat - there's only one instance, so any
per-repetition state has to be external, etc.

The issues of parent/child communication were one of the main reasons for
the reworking of the bindings system into the events system used in the
current snapshot.  In fact, come to think of it, the current snapshot
doesn't have that problem.  You'd just do this:

addHandlers
  (template elementNamed: 'previousMonth')
    month: ....

  (template elementNamed: 'currentMonth')
    month: ...

However, this wouldn't work as well when you had subcomponents dynamically
changing their class, (ie the earlier thread with tim on question types),
since that implies subcomponents being created multiple times in the
lifetime of a template.  So likely this will evolve into something like

addHandlers
  (template elementNamed: 'previousMonth')
    onCreation: [:m | m month: ...]