try attaching it to a component inside a page, see if that helps. eg
webmarkupcontainer c=new webmarkupcontainer("c"); add(c);
c.add(behave);

-igor

On Tue, Feb 3, 2009 at 10:16 AM, insom <[email protected]> wrote:
>
> I'm trying to apply the concepts found here:
> http://cwiki.apache.org/confluence/display/WICKET/Calling+Wicket+from+Javascript
> . The code for my very simple test case is below. When I load the page, I
> expect to see "hi" printed to my console. Instead I get a
> NullPointerException (also shown below). What am I doing wrong?
>
> public class AjaxTestPage extends WebPage implements IHeaderContributor {
>
>        final AbstractDefaultAjaxBehavior behave = new
> AbstractDefaultAjaxBehavior() {
>                @Override
>                protected void respond(AjaxRequestTarget target) {
>                        System.out.println("hi");
>                }
>        };
>
>        public AjaxTestPage() {
>                add(behave);
>        }
>
>        @Override
>        public void renderHead(IHeaderResponse response) {
>                response.renderOnLoadJavascript(
>                                " wicketAjaxGet('" + behave.getCallbackUrl() + 
> "', function() { },
> function() { }); "
>                );
>        }
> }
>
>
> java.lang.NullPointerException
>        at com.insom.ErrorPage.<init>(ErrorPage.java:19)
>        at
> com.insom.MyWebRequestCycle.onRuntimeException(MyWebRequestCycle.java:24)
>        at
> org.apache.wicket.request.AbstractRequestCycleProcessor.onRuntimeException(AbstractRequestCycleProcessor.java:217)
>        at
> org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:119)
>        at org.apache.wicket.RequestCycle.step(RequestCycle.java:1302)
>        at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1353)
>        at org.apache.wicket.RequestCycle.request(RequestCycle.java:497)
>        at
> org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:387)
>        at
> org.apache.wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:124)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>        at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>        at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>        at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>        at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
>        at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
>        at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>        at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>        at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>        at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
>        at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
>        at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
>        at 
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
>        at java.lang.Thread.run(Thread.java:619)
>
> --
> View this message in context: 
> http://www.nabble.com/Implementing-the-cwiki%27s-%22Calling-Wicket-from-Javascript%22-tp21815652p21815652.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

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

Reply via email to