wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grigorov <mgrigo...@apache.org>
Subject Re: Error while calling Wicket from a JavaScript function
Date Wed, 18 Jan 2017 09:07:56 GMT
There is no variable named 'a' in your code snippet.
It might be another problem.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Jan 18, 2017 at 10:04 AM, James Selvakumar <james@mcruncher.com>
wrote:

> Hi Martin,
>
> I tried your suggestion but I'm still getting the same TypeError.
>
> On Wed, Jan 18, 2017 at 4:55 PM, James Selvakumar <james@mcruncher.com>
> wrote:
>
> > Thanks Martin for the super fast reply. I'll try that out.
> >
> > On Wed, Jan 18, 2017 at 4:54 PM, Martin Grigorov <mgrigorov@apache.org>
> > wrote:
> >
> >> var wcall = Wicket.Ajax.get({ u: '${callbackUrl}'});
> >> should be
> >> var wcall = Wicket.Ajax.get({ u: window.callbackUrl });
> >>
> >> Martin Grigorov
> >> Wicket Training and Consulting
> >> https://twitter.com/mtgrigorov
> >>
> >> On Wed, Jan 18, 2017 at 9:51 AM, James Selvakumar <james@mcruncher.com>
> >> wrote:
> >>
> >> > 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
> >> >
> >>
> >
> >
> >
> > --
> > Thanks & regards
> > James Selvakumar
> >
>
>
>
> --
> Thanks & regards
> James
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message