Hi,

I have done some work integrating YUI LayoutManager to get nice resizable, collapsable panels. To get nested LayoutManagers to work was a bit tricky and I would like to describe my implementation to make sure there is no simpler approach.

My test page can be seen here running on Google App Engine

http://test-1.latest.live-guides.appspot.com/

The child script to render itself has to be called in the "render" event of the parent LayoutManager otherwise the parent isn't complete and all hell breaks loose. See here for details

http://developer.yahoo.com/yui/examples/layout/nested_layout.html

So the scripts that render the parent and child have to be interleaved to work like this

<head>
        <script>
                // some stuff contributed from parent component
                // some stuff contributed from child component
                // the final stuff from child component
                // the final stuff from parent component
        </script>
</head>

I also had this problem while rendering a Google Map V3 into a LayoutUnit. Unitl the LayoutManager has finished its rendering the map thinks it is really really big and starts to load tons of tiles.

My solution was to make both GoogleMapComponent (my impl for V3 with ajax callbacks) and LayoutManager implement an interface RenderScriptProvider which would either contribute the render script to the <head> or include it in a parent components render script. A flag makes sure it is only called once and is reset in onBeforeRender so that Ajax repaints still work.

This works fine with my two components but another existing components that might also break would not work correctly when place in a LayoutUnit.

I was thinking that perhaps calling IHeaderContributor.renderHead() on every child and somehow adding the JavaScript results to the parent LayoutManagers render script might work? But how would you make sure it was also not contributed to the head again?

Cheers,

JD






---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to