Dear Wicket team,

I need to make a call to a Wicket page from my JavaScript function.
I followed the guide Calling Wicket from Javascript
<https://cwiki.apache.org/confluence/display/WICKET/Calling+Wicket+from+Javascript>
and managed to define an ajax behavior to respond to the JavaScript call.

My ajax behavior looks like this:

> private final AbstractDefaultAjaxBehavior behave = new 
> AbstractDefaultAjaxBehavior()
> {
>     protected void respond(final AjaxRequestTarget target)
>     {
>         LOGGER.debug("Received a request from client to get the encryption 
> key");
>         target.add(new Label("foo", "Yeah I was just called from 
> Javascript!"));
>     }
>
>     public void renderHead(Component component, IHeaderResponse response)
>     {
>         super.renderHead(component, response);
>         String callbackUrl = getCallbackUrl().toString();
>         response.render(JavaScriptHeaderItem.forScript("var callbackUrl='" + 
> callbackUrl + "';", "values"));
>     }
> };
>
> This callback url got rendered in the page like this:

<script id="values" type="text/javascript">
> /*<![CDATA[*/
> var callbackUrl='./wicket/page?0-1.IBehaviorListener.0-';
> /*]]>*/
> </script>
>


And here is my JavaScript code:

> var wcall = Wicket.Ajax.get({ u: '${callbackUrl}'});
> alert(wcall);
>
> But I'm getting the following error in the Wicket Ajax Debug Window:

*An error occurred while executing Ajax request:TypeError: a is undefined*
>

Can someone point out what's the mistake here?

-- 
Thanks & regards
James

Reply via email to