Back in the good old 0.93 days, I had a sketch for a little calendar app. I include it here for old times sake.
OK, I go to convert it into 0.94.
The way the calendar is supposed to work is that each day on the calendar has a color attached to it. You basically draw the days with the code in the RVCalendar>>html template with in 0.93 :
( tr repeat: '@week/weeks' ( td repeat: '@aDay/week' ( div align: center (font size: '+1' ( a sea:id: dayJump '[aDay.dayOfMonth]' ))) ) )
assign the color of the day with the binding:
addBindingsTo: template
(template elementNamed: 'aDay/week') set: #bgcolor toPath: 'dayBackground'.
where RVCalendar>>dayBackground figures out which day it is by
subjectDay := locals at: #aDay
Fair enough.
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.
Also, I a DNU barks at me when it gets to the
aDay.dayOfMonth
line, saying that it 'Could not find value for key "dayOfMonth"'.
What am I missing? I assume that I'm messed up in the addHandler method.
Jim
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
----- Original Message ----- From: "Avi Bryant" avi@beta4.com To: seaside@lists.squeakfoundation.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
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...
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 '[aDay.dayOfMonth]' ))) ) ) )
'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' ...))
addHandlers (template elementNamed: 'dayCell') onDisplay: [:cell | cell attributeAt: #bgcolor put: self
dayBackground]
I did this and it worked.
When do you have to fiddle with the #list: and #iterator: messages in addHandler?
Thanks,
Jim
On Wed, 26 Jun 2002, Jim Benson wrote:
'week' is the name of the local in the tr repeat. I'm not sure how you're supposed to address it.
locals at: #week. Although in the current version in CVS I'm trying to move towards template localAt: #week since I would like to separate the whole notion of templates and locals into a distinct, optional system.
When do you have to fiddle with the #list: and #iterator: messages in addHandler?
Rarely. I'm pretty sure I never have.
Cheers, Avi
seaside@lists.squeakfoundation.org