- @JsFunction exported to JS doesn't have apply() and call() operations. Apply() is used by JQuery (2.1.3) to call callbacks, so basically it wasn't possible to add handlers using JQuery. See other thread on this: https://groups.google.com/forum/#!topic/google-web-toolkit/PHtfLTSAJDM
Hi,I was playing a bit with the new JsInterop on trunk build. After some conversation with Goktug, I was to write some of issues I've found. It was April 3 build, sorry didn't check if anything changed since then. So, here it goes:
- @JsFunction exported to JS doesn't have apply() and call() operations. Apply() is used by JQuery (2.1.3) to call callbacks, so basically it wasn't possible to add handlers using JQuery. See other thread on this: https://groups.google.com/forum/#!topic/google-web-toolkit/PHtfLTSAJDM
- js() function is not yet available.
- 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")
- @JsProperty set on methods were not available in JS.
- Couldn't access class with @JsExport annotation from JS.
I've workarounded the @JsFunction issue by adding .apply() in JS, so I've made it work. And I must tell, the new JsInterop is really GREAT!I also used @JsType with @JsProperty to access a JSON returned from server. I just used JSON.safeEval() and casted to @JsType interface. It worked great! I hope it could be a replacement for me of AutoBeans, if only the JS arrays and Java collections were unified.Regards,Marcin Okraszewski
--
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 google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/af52b996-9bec-41d0-9768-934e0371270a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
/**
* Create a function that applies the specified samMethod on itself, and whose __proto__ points to
* <code>instance</code>.
*/
public static native JavaScriptObject makeLambdaFunction(JavaScriptObject samMethod,
JavaScriptObject instance, int jsThisArgPosition) /*-{
var lambda = function() {
var args = arguments;
if (jsThisArgPosition >= 0) {
args.splice(jsThisArgPosition, 0, this);
}
return samMethod.apply(lambda, args);
}
lambda.__proto__ = instance;
return lambda;
}-*/;
--
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 google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/97624985-35bf-48d6-b187-76181d9b8672%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscribe@googlegroups.com.
- 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")
- Couldn't access class with @JsExport annotation from JS.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAPVRV7e-HtaWNMSHWUQM8zkeGS1Ncz1hKaJiFr4_Occ4kArNFw%40mail.gmail.com.
Hi Goktung,I've compiled the latest version from trunk and rechecked those items you wanted the snippets for.
- 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
- 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() {}@JsExportpublic String sayHello() {return "Hello World!";}}JavaScript:var hello = new interop.Hello();alert(hello.sayHello());Result:Uncaught ReferenceError: interop is not definedMarcin
--
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 google-web-toolkit-co...@googlegroups.com.
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.
@JsNamespace("interop")@JsExport@JsTypepublic class Hello {@JsExport
public Hello() {}public String sayHello() {
return "Hello World!";}@JsExportpublic static String sayHelloStatic() {return "Hello World!";}}
JsExport is no longer fully qualified, you need to supply JsNamespace. Try following:@JsNameSpace("interop") @JsExportclass Hello {public Hello() {}public String sayHello() { .. }}Also you need to put @JsType if you want to call sayHello from javascript.
public Hello() {}@JsExportpublic String sayHello() {return "Hello World!";}}JavaScript:var hello = new interop.Hello();alert(hello.sayHello());Result:Uncaught ReferenceError: interop is not definedMarcin
--
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 google-web-toolkit-contributors+unsubscribe@googlegroups.com.
A word of comment on @JsType - that was completely not intuitive that I still need to add @JsType if I use @JsExport.
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.
Once I instantiated the class from the module load, it started to complain about @JsExport on non-static method
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-co...@googlegroups.com.
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.
--
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 google-web-toolkit-co...@googlegroups.com.
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.
Are you passing the flag to enable JsInterop for your project?
--
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 google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/e6bd7cb2-2742-4192-bada-eb3eac9bc30e%40googlegroups.com.
No worries.One thing I didn't fully understand is; is this still broken for SuperDevMode or not?
On Mon, May 4, 2015 at 2:46 PM, Marcin Okraszewski <okr...@gmail.com> wrote:
Are you passing the flag to enable JsInterop for your project?I was adding "-XjsInteropMode JS" only in SuperDevMode. This question made me realize I didn't for the compilation, when I was testing in external web server. So it works like charm with normal compilation running on external web server, when I add " -XjsInteropMode JS" to compilation parameters. I now feel like in those support quotes - "Did you plug your computer?" ... Sorry I did take you so much time for finding yet another user error.Regards,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 google-web-toolkit-contributors+unsubscribe@googlegroups.com.
I wasn't able to make it run in SuperDevMode. Worked only in the normal compilation. The idea to try it with normal compilation was from this thread: https://groups.google.com/forum/#!msg/google-web-toolkit-contributors/u1BKRUsjjgI
The launch config is part of the project attached to my yesterday message: https://groups.google.com/d/msg/google-web-toolkit-contributors/QrkNflMKe9E/-3XhHdOXfDsJThe arguments passed to dev mode are as follows: "-superDevMode -remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -startupUrl index.html -logLevel INFO -codeServerPort 9997 -port 8888 -XjsInteropMode JS -war C:\workspaces\gwt-demo\interop-problems\war com.cloudorado.jsinterop.InteropProblems"I'm testing with build from trunk done morning Apr 29.Regards,Marcin
On Monday, 4 May 2015 23:54:15 UTC+2, Goktug Gokdogan wrote:
No worries.One thing I didn't fully understand is; is this still broken for SuperDevMode or not?
On Mon, May 4, 2015 at 2:46 PM, Marcin Okraszewski <okr...@gmail.com> wrote:
Are you passing the flag to enable JsInterop for your project?I was adding "-XjsInteropMode JS" only in SuperDevMode. This question made me realize I didn't for the compilation, when I was testing in external web server. So it works like charm with normal compilation running on external web server, when I add " -XjsInteropMode JS" to compilation parameters. I now feel like in those support quotes - "Did you plug your computer?" ... Sorry I did take you so much time for finding yet another user error.Regards,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 google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/e6bd7cb2-2742-4192-bada-eb3eac9bc30e%40googlegroups.com.
--
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 google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/bffa2a4f-8b2e-4f5c-aed6-46f1529167e6%40googlegroups.com.
GET /clean/interop_problemsCleaning disk caches.Cleaned in 2ms.GET /recompile/interop_problemsJob com.cloudorado.jsinterop.InteropProblems_1_2starting job: com.cloudorado.jsinterop.InteropProblems_1_2binding: user.agent=safariskipped compile because no input files have changed0,043s total -- Compile completed
--
You received this message because you are subscribed to a topic in the Google Groups "GWT Contributors" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit-contributors/QrkNflMKe9E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAN%3DyUA0WZFPQ%2B2YzG5xXTPjd6waN8ZQkGJs%3D3SLoKMF09SMXrA%40mail.gmail.com.
Ok, JsFunction call/apply issue should be fixed as of https://gwt-review.googlesource.com/#/c/12810/. Can you verify that for me?You cannot still access JQuery bound 'this'. However note that the same issue also exists for ES6 arrow functions.According to [1] this could be worked around in JQuery's case via event.currentTarget.This required some restrictions and I put others as well so that one day we can generate a completely real function from it.
On Wed, Apr 29, 2015 at 2:19 PM, Goktug Gokdogan <gok...@google.com> wrote:
I think this could be handled by @JsConvert that is specific for jQuery instead of a custom annotation.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/97624985-35bf-48d6-b187-76181d9b8672%40googlegroups.com.
--
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 google-web-toolkit-contributors+unsubscribe@googlegroups.com.