[Bese-devel] :template options referring to data within the "current" component

Anthony Juckel ajuckel at gmail.com
Tue Sep 21 01:53:24 UTC 2004


I'm still relatively new to the internals of UCW, so the following may
be a very simple question.

Is there a way to refer to the current component when supplying
:template options?

For example, I have a set of classes: foo, bar and baz.  The basic
interaction for dealing with each of these objects is the same, I only
wish for the template to be different depending on which is being
edited.

What seems reasonable, would be to have a component defined as such:

(defcomponent editor (standard-component)
   ((object :accessor object :initarg :object))
   (:template (get-edit-template-for-object _object_)))

Then, I have get-edit-template-for-object defined for any object that
I can safely pass to this editor component.  The problem is, _object_
in the above is an unbound symbol.

I see that gen-component-default-render-on (from
standard-component.lisp) generates a defmethod form which gives the
default render-on implementation when :template is used.  This
defmethod uses gensyms for the response and component parameters. 
Would it be reasonable to make one or both of these standard symbols? 
Users would have to be aware that, for example, 'response and
'component are already bound within the body of their :template form,
but that seems a rather small price to pay to be able to have
components using templates refer to themselves when deciding on a
template (or tal environment bindings).  I've made this change
locally, and in simple tests nothing seems to break.  Does anyone see
any problems with this approach?

On the other hand, perhaps I'm reading this all wrong and what I want
is already available some other way...

Anthony W. Juckel




More information about the bese-devel mailing list