[Seaside] Newbie: How to add different IAComponent's?

Avi Bryant avi@beta4.com
Sat, 25 May 2002 14:59:30 -0700 (PDT)

Hi Lukas, and welcome.

The basic problem with your approach is that you are trying to generate
the template at runtime.  This isn't, fundamentally, the way Seaside works
- it expects the template to be a static specification of layout, and for
dynamism to be implemented at a higher level than textual manipulations of
HTML.  The most important thing to realize here is that the template is
cached, and thus doing anything other than returning it as a literal from
the #html method is going to give you strange results.  Some people still
prefer to think in terms of manually generating HTML, and I've been trying
to find ways to make that work with the rest of the system, but don't have
anything concrete yet.

As for what the "right" way to do what you're trying to do, take a look at
IATabSheet.  There isn't any example that exercises it right now, but a
sample use is something like:

  ^ '<page sea:id="tabsheet">
	<div sea:id="tab=Foo">
	   <page sea:id="fooPage">
	<div sea:id="tab=Bar">
	   <page sea:id="barPage">

addBindingsTo: template
  (template elementNamed: 'tabsheet')
    class: IATabSheet;
    set: #tabs to: #(Foo Bar ...)

   (template elementNamed: 'fooPage')
     class: ...

You'll note that this assumes a static knowledge of what the pages are.
One of the limitations of seaside right now is that the structure of
subcomponents is more or less assumed to be predetermined.  It is
possible to get around this (IAInspectorFrame is an example) by explicitly
manipulating the 'children' dictionary of the component, but it's ugly.
I'm playing with ways to improve this... one thing that would be nice
would be a generic concept of a "polymorphic subcomponent", where the
subcomponent used depends on the class of some piece of data.

Hope that was some help.  Let me know if it works out.