[Seaside] Woohoo, made a list of links! Now for the next bit...

Avi Bryant avi@beta4.com
Sun, 12 May 2002 23:52:19 -0700 (PDT)

On Sun, 12 May 2002, Tim Rowledge wrote:

> QuestionPage>html to
> ^'[question.description]'
> from
> ^question description
> and it now updates appropriately. Duh?

Ah.  Explanation: templates are expected to be static and are thus cached
after parsing (the cache is cleared when methods are added/changed, so
this is usually pretty transparent).  If the html was actually parsed
every time you saw a page things would be much slower.

> > in sync with attributes of the parent.  For example,
> >
> >   parent bar: (child x)
> >
> > after every request.
> By 'after every request' I guess you mean after the stuff done by the
> child has completed and returned?


> > Now, this is basically
> >
> >   child onAnswer: [:v | parent answerQuestion: v]
> >
> > Does that make any more sense?
> A little - but the crucial confusion I'm suffering right now is how that
> is invoked.

Well, that would get invoked whenever the child wanted to invoke it.  That
is, presumably the child's onAnswer: method is going to store that block
away in an inst var, and at some later point (when one of its action
methods is called), is going to evaluate that block.  None of this is
necessary, as the child could just directly call 'parent answerQuestion:
foo' at that point instead, I was just trying to illustrate some uses of

> In fact I'm a bit puzzled about what invokes any of
> the bindings. For example, I have the #question binding on the
> questionPage element and it makes reasonable sense now; but nowhere that
> I can see have I done anything to invoke it; my questionPage #html is
> nothing more than the text of the question right now.
> Are all the bindings invoked on every display? If so, in what order?

The value of each binding is retrieved on every display, yes.  Note that
for method bindings this does not mean the method is invoked, just that a
block is retrieved which would invoke the method if it were invoked

Order is undefined.  For more detail, look at these
methods in IAComponent: #bind:to:, #pullBindings, #pushBindings.

> <a sea:id="onAnswer:">Answer</a>'
> but I dont see where the argument for #onAnswer: would come from.

Anchors and such take an 'argument' binding which provides the argument to
methods they invoke.  By default this is 'locals.last', which means that
the method gets passed the top of the locals stack.  This means that if
you have something like

<li sea:id="each/foo">
  <a sea:id="bar:">[each]</a>

Then #bar: will get passed the current value of 'each' (that is, the value
of each that corresponds to the particular link you clicked on).