You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Johan Compagner <jc...@gmail.com> on 2006/11/21 11:46:34 UTC

headercontribution in AjaxRequestTarget

Hi,

I already changed something in my local 1.3 code for duplicate headers
(before the backport)
instead of doing this:

        component.renderHead(header);
        component.detachBehaviors();
        if (component instanceof MarkupContainer)
        {
            ((MarkupContainer)component).visitChildren(new
Component.IVisitor()
            {
                public Object component(Component component)
                {
                    if (component.isVisible())
                    {
                        component.renderHead(header);
                        component.detachBehaviors();
                        return CONTINUE_TRAVERSAL;
                    }
                    else
                    {
                        return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
                    }
                }
            });
        }

i do this:

        component.renderHead(header);
        if (component instanceof MarkupContainer)
        {
            ((MarkupContainer)component).visitChildren(new
Component.IVisitor()
            {
                public Object component(Component component)
                {
                    if (component.isVisible())
                    {
                        component.renderHead(header);
                        return CONTINUE_TRAVERSAL;
                    }
                    else
                    {
                        return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
                    }
                }
            });
        }
        component.detachBehaviors();
        if (component instanceof MarkupContainer)
        {
            ((MarkupContainer)component).visitChildren(new
Component.IVisitor()
            {
                public Object component(Component component)
                {
                    if (component.isVisible())
                    {
                        component.detachBehaviors();
                        return CONTINUE_TRAVERSAL;
                    }
                    else
                    {
                        return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
                    }
                }
            });
        }

i guess i don't have to do that anymore now because detachBehaviours doesn't
do much now anymore
Except when we are planning to make Behaviours this way that they can be
shared between components...
if that is the case then detach should only be done after everything is
rendered...

Cant we remove detachBehaviours from Component?
Why is that method there. In an ajax request also Component.detachModels()
should also be called
(the model should be detached from the component so detachModels() should be
called i guess but i don't see it right now)


In the new HeaderContribution i see we have a flag:
setFlag(FLAG_HEAD_RENDERED, true);
i guess that really only needs to be set to false again in a full page
render? So that we only render the header once?
and after that not again in an ajax request (except for new components)

johan