On Mon, May 4, 2015 at 4:07 AM, Marcin Okraszewski <[email protected]> wrote:

> Hi,
> Sorry for the delay. I still wasn't able to make @JsExport work for me.
> One thing I was for sure missing is I've never used the class in my GWT
> project. It was referenced only from JS.
>

We already have a test covering that and it is passing (see
MyClassExportsMethodWithoutReference)


> Once I instantiated the class from the module load, it started to complain
> about @JsExport on non-static method
>


Are you passing the flag to enable JsInterop for your project?


> , which I interpret that it wasn't processed earlier. I also tried with
> compiled version served from a webserver, not from Super Dev Mode. In case
> it was happening in dev mode only.
>
> The method now looks as below and I'm still having errors that "interop"
> is undefined. I attach the project in question.
>
> A word of comment on @JsType - that was completely not intuitive that I
> still need to add @JsType if I use @JsExport.
>
> @JsNamespace("interop")
> @JsExport
> @JsType
> public class Hello {
> @JsExport
> public Hello() {
> }
>  public String sayHello() {
> return "Hello World!";
> }
>
> @JsExport
> public static String sayHelloStatic() {
> return "Hello World!";
> }
> }
>
>
> Regards,
> Marcin Okraszewski
>
>
> JsExport is no longer fully qualified, you need to supply JsNamespace. Try
>> following:
>>
>> @JsNameSpace("interop") @JsExport
>>         class Hello {
>>            public Hello() {}
>>            public String sayHello() { .. }
>>         }
>>
>> Also you need to put @JsType if you want to call sayHello from javascript.
>>
>>
>>
>>> 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/7a6094ef-da19-42ff-bf93-3e90a202fe5a%40googlegroups.com
>>> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/7a6094ef-da19-42ff-bf93-3e90a202fe5a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> 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/da3a45aa-08ef-419a-8cfa-0007a1fc9487%40googlegroups.com
> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/da3a45aa-08ef-419a-8cfa-0007a1fc9487%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAN%3DyUA010v22PA8TVzzFe7gDWrLCKeOqrbW7eQi6wfnL%3DqyqcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to