your page should implement IHeaderContributor

or attach a behaviour to your components.

for instance (first snippet i found out there):

private static class MyJSBehavior extends AbstractBehavior {
       private static final long serialVersionUID = 1L;
       @Override
       public void renderHead(IHeaderResponse response) {
           super.renderHead(response);
           response.renderOnDomReadyJavascript("alert('test');");
       }
   }


this is widely documented so you should be able to find better
examples, but that's the way to go

francisco


On Tue, Dec 16, 2008 at 8:51 PM, Marvan Spagnolo <[email protected]> wrote:
> Hi,
> I'm trying to write some javascript in a page's markup (subclass of another
> page using <wicket:child>/<wicket:extend> mechanism)
> via JavascriptUtils.writeJavascript().
>
> The fact is it doesn't do anything at all nor I can't find anything related
> in the stack trace (the page displays well with no exceptions nor problems
> at all),
> the expected javascript is simply not in the generated markup.
> Before calling JavascriptUtils I add a form to the page (which works
> normally as expected).
>
> The actual code looks like:
>
> ---
> public class MyPage extends MyBasePage
> {
>     public MyPage()
>     {
>         add( new MyForm( "formid" ));
>         String js = "... javascript code here ...";
>         JavascriptUtils.writeJavascript( getResponse(), js);
>     }
> }
> ---
>
> Can anyone please help ? Should I maybe use something else instead of
> getResponse() ?
> I expected that the javascript would have been written before the
> </wicket:extend> closing tag, or wherever but it's not in the markup at all.
> I'm using wicket 1.3.5 on tomcat 6 and jdk 1.6.
>
> Reza Marvan Spagnolo
>

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

Reply via email to