Monday, September 27, 2010

Re: Calling GWT method from javascript

Check out the JSNI Dev Guide here: http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html

On Mon, Sep 27, 2010 at 6:23 AM, Murphy <connal.murphy@gmail.com> wrote:
Hi,
As the subject says, I'm having a problem calling a GWT method from
Javascript.

I'm pretty sure the GWT side of things is set up correctly because
this works:
  <button onclick="alert(hello('fooBar'))">Say Hello</button>
So when I click on the button, my exported JSNI method (called
'hello') is correctly invoked and I see the alert.

But the following code does not work
   <script type="text/javascript">
       alert(hello('fooBar'));
   </script>

Nor does this:
   <script type="text/javascript">
       function sayHello(name) {
           alert(hello(name))
       }
       sayHello('fooBar');
   </script>

Instead, I just see an message in the Firebug console saying "hello is
not defined"

Any ideas as to what I'm doing wrong?
As far as I can see, I've faithfully followed the instructions given
in various places for what I'm trying to achieve (e.g.
http://code.google.com/p/gwtchismes/wiki/Tutorial_ExportingGwtLibrariesToJavascript_en)

Any & all help appreciated ...

Cheers,
CM

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment