[Seaside] Updating sub-components: where?
Michael Neumann
mneumann at ntecs.de
Mon Feb 21 09:37:07 CET 2005
Avi Bryant wrote:
> On Sat, 19 Feb 2005 12:17:17 +0100, Martin J. Laubach <mjl at laubach.at> wrote:
>
>> Is there a method that is called before a page is being built? I want
>>to update the visual state of my component depending on some global
>>session
>>state, possibly changing/adding some subcomponents.
>>
>> I'm currently doing that in #children, but (a) that is called twice (I
>>guess once for the redirect, once for the real page), and (b) it
>>probably
>>(most certainly?) is not what was intended for #children.
>>
>> Where to do that?
>
Hi Avi,
> As a general piece of advice, I've found that Seaside apps work much
> better when built with a pull model instead of push: for example,
> determine your current subcomponents on the fly based on the state of
> the world, rather than trying to keep a list constantly up to date.
> Polling is almost always simpler and more robust than notifying, and
> in a web application the refresh rate is low enough that there are
> usually no performance concerns.
I currently have a similar problem. So you suggest to rebuild the
children array on each render, right?
Do you favor an extra children-build step or doing that in-place, too?
Something like this (in Ruby):
def render
@children.clear
for obj in domain_objects
r.render add_child(editor_for(obj))
end
end
In this case, wouldn't it be nice if "r.render" automatically adds each
rendered child to the children array? Maybe:
def render
for obj in domain_objects
r.render_child editor_for(obj)
end
@children = r.rendered_children
end
Or another idea is to leave @children for static childs and have an
@dynamic_children array, which would be reset before each render-phase
and include the rendered children.
Regards,
Michael
More information about the Seaside
mailing list