[Seaside] dynamic subcomponents proposal
Sat, 15 Jun 2002 18:58:50 -0700 (PDT)
Actually this affects subcomponents pretty generally, but it's motivated
by Tim's (and others) request for subcomponents with dynamic class. What
I'm currently thinking about doing is this:
- rather than configuring subcomponents in an #addHandlers (or
#addBindingsTo:) method, each subcomponent will have a creation method in
its parent. These will follow some sort of naming convention, ie, the
subcomponent named 'questionPane' would be created by
#subcomponentQuestionPane. The responsibility of this method is to
create, configure, and return a subcomponent. For example, it might look
^ QuestionComponent new
message: 'Answer the following question:'
onDisplay: [:q | q question: self question]
onUpdate: [:q | answer := q answer]
- if the creation method takes 0 arguments, it is called only once in a
- if the creation method takes 1 argument, it is called for every display
of the subcomponent, and is passed the current instance of that
subcomponent. The method can choose to return either the existing
subcomponent or a new one. For example,
^ current class = self question componentClass
[self question componentClass new
- are those rules too implicit? Is there a better way to do it (split it
into two methods, one to decide whether to create and one to create)?
- this draws a very strong line between simple template elements (ie,
checkboxes) and full subcomponents. I used to think that was a bad idea,
but it's bothering me less these days.
What do y'all think?