Hello, I have a need for an interface that is a twin to IHeaderContributor, but which will contribute javascript to be executed after the html has been rendered on the client. I realize all the hooks are there with WebPage.getBodyContainer().addOnLoadModifier(), and AjaxRequestTarget.appendJavascript(), but this requires the component/behavior to know what the current RequestTarget is. I have several instances in my current project where hierarchies of components and behaviors can be rendered through a page request or ajax request and need initialization script executed on the client once the dom is in place. I also have use cases where a component must contribute to both head and foot. One option is to have the component inject the script in rendered(), but not all browsers support script blocks inside arbitrary elements (IE in particular).
To solve this particular issue I would like to propose an interface and see if anyone agrees that it has a place in wicket (or thinks I should go away and code my own solution :)). For the sake of argument, let's call it IOnLoadContributor and it will have two methods: renderOnLoad and renderFoot. This interface will tag components and behaviors in the same way that IHeaderContributor does and allow them to contribute init functions and script blocks without regard to whether the target is a page request or ajax request. If the target is a page request, init functions go to body onload, and script blocks will be emitted just before </body>. For AjaxRequestTargets, both will be written to appendJavascript. WDYT? If the answer is "code it yourself", any implementation advice will be greatly appreciated. thanks in advance, jim
