Maybe to supplement a bit - the JavaScript code is run in onclick handler,
so GWT is already loaded. A wider scope would be:
<script type="text/javascript" language="javascript">
function sayHello() {
var hello = new interop.Hello();
alert(hello.sayHello());
}
</script>
...
<button onclick="sayHello();">Say hello</button>
Marcin
On Wednesday, 29 April 2015 16:53:37 UTC+2, Marcin Okraszewski wrote:
>
> Hi Goktung,
> I've compiled the latest version from trunk and rechecked those items you
> wanted the snippets for.
>
>
>>> 1. I wasn't able to call methods on jQuery object returned from JSNI
>>> when using just @JsType annotation. It only worked when I used
>>> @JsType(prototype="jQuery")
>>>
>>>
> It didn't happen this time. So either
>
>
>>
>>> 1. Couldn't access class with @JsExport annotation from JS.
>>>
>>>
> I had multiple tries of using @JsExport as well as @JsNamespace. This is
> one of them:
>
> public class Hello {
> @JsExport("interop.Hello")
> public Hello() {
> }
> @JsExport
> public String sayHello() {
> return "Hello World!";
> }
> }
>
> JavaScript:
>
> var hello = new interop.Hello();
> alert(hello.sayHello());
>
> Result:
>
> Uncaught ReferenceError: interop is not defined
>
> Marcin
>
>
--
You received this message because you are subscribed to the Google Groups "GWT
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-web-toolkit-contributors/c819123d-2967-4f12-ba29-326bc4caf837%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.