[Seaside] Iterators in 0.94

Avi Bryant seaside@lists.squeakfoundation.org
Wed, 26 Jun 2002 11:09:31 -0700 (PDT)


On Wed, 26 Jun 2002, Jim Benson wrote:

> I start my 0.94 conversion. I know that I have to create an addHandler
> method for the IARepeatIterator. I thought it would be something along the
> lines of:
>
>
>  (template elementNamed: '@aDay/week')
>   onDisplay: [:r |
>    r list: #week; iterator: #aDay;
>    attributeAt: #bgcolor put: self dayBackground].
>
> but when I get into >>dayBackground, there is nothing in the locals to
> indicate that there is anything associated with #aDay.

Right.  So there are two problems here.  One is that you're giving it
#week as the collection, which I'm pretty sure isn't what you want (it
would iterate over $w, $e, $e, $e, $k...).  Pass it the actual collection
instead (on the other hand, the symbol is right for #aDay, since that's
just telling it what to name the local).  However, you don't actually need
this part, because...

the other problem is that onDisplay only gets called once for the list as
a whole, which means that your #attributeAt:put: will also only get called
once.  I played with some kludges to change this behavior, but ultimately
the way to fix it is to do this:

(span repeat: '@aDay/week'
  (td sea:id: 'dayCell'
    ...))

addHandlers
  (template elementNamed: 'dayCell')
    onDisplay: [:cell | cell attributeAt: #bgcolor put: self dayBackground]

That seem reasonable?

Avi