[Seaside] Iterators in 0.94
Wed, 26 Jun 2002 11:05:59 -0700
----- Original Message -----
From: "Avi Bryant" <firstname.lastname@example.org>
Sent: Wednesday, June 26, 2002 11:09 AM
Subject: Re: [Seaside] Iterators in 0.94
> 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
> > 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...
Right I bungled that because:
( tr repeat: '@week/weeks'
( span repeat: '@aDay/week'
(td sea:id: 'dayCell'
( div align: center (font size: '+1' ( a sea:id: dayJump
'week' is the name of the local in the tr repeat. I'm not sure how you're
supposed to address it.
> 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'
> (template elementNamed: 'dayCell')
> onDisplay: [:cell | cell attributeAt: #bgcolor put: self
I did this and it worked.
When do you have to fiddle with the #list: and #iterator: messages in