[Seaside] Setting instance variables
Thu, 6 Jun 2002 00:33:09 -0700
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
I need to think a little about this before making any suggestions, but at
least there is a method that works under this scheme currently :-)
----- Original Message -----
From: "Avi Bryant" <email@example.com>
To: "Jim Benson" <firstname.lastname@example.org>
Sent: Thursday, June 06, 2002 12:20 AM
Subject: Re: [Seaside] Setting instance variables
> On Wed, 5 Jun 2002, Jim Benson wrote:
> > [Each calendar has a previous/next button, so that the user can flip
> > the calendar]. I haven't been able to figure out when or how to do that
> > Seaside, which probably indicates that I don't quite understand how the
> > instance creation sequence takes place, or where to jump in when I want
> > fiddle around with something that the template creates.
> Right. The way you jump in to fiddle with the template is in the
> #addBindingsTo: method. There's actually no easy way to get hold of the
> instance as it's created to initialize it, which in retrospect there
> probably should be (suggestions for how this wants to work are welcomed).
> However, you can use bindings to do what you need, if somewhat awkwardly.
> In particular, I would:
> - add instance variables for, say, currentMonth and previousMonth to the
> - initialize these to the correct month values in the parent's #initialize
> - do one of two things:
> - explicitly add bindings in the parent's addBindingsTo: method such as
> (template elementNamed: 'previousMonth')
> bind: #month toPath: 'previousMonth'
> - or, write a defaultBindings method for your month component that sets
> up a binding based on its id:
> self bind: #month toPath: id
> Now whenever you use a month component, it'll default to syncing itself
> with a month instance variable in the parent with the same name as its id.
> Note that this doesn't just provide for initialization - the inst vars in
> the parent will always reflect the current month in the components (and
> changing them will also change the components).
> That make any sense at all?