That has been a very clarifying response.
JsInterop seems to fit better with what I need from GWT. A fast way to build a gate between new code written in Java and existing libraries in JavaScript. I read a little about JSNI some days ago but it didn't attracted me too much, sincerely. Although I understand that it still is the best method to write a functionality that is implemented in a different way by each browser. Fortunately this is less frequent nowadays.
About Elemental 2.0, that's another thing that will be really useful. It sounds exciting to have an API that's constantly up to date with the W3C standards.
Now I'm going to take a look to the document about JsInterop that you've indicated.
Thank you, Jens and the other users, for having spent your time to clarify my doubts.
On 26/10/15 17:34, Jens wrote:
--Currently the heart of GWT is JSNI which allows you to define a Java method and implement it using JavaScript. So whenever GWT code interacts with JavaScript it is done through JSNI. With GWT 2.8 there will be JsInterop v1.0 which allows you to define interfaces/classes along with annotations to access browser or general JavaScript APIs. This is done based on naming conventions. You can read more about JsInterop here: https://docs.google.com/document/d/10fmlEYIHcyead_4R1S5wKGs1t2I7Fnp_PaNaa7XTEk0/edit#
With JsInterop most JSNI code will go away as JSNI code is often just a one liner mapping from Java world to JavaScript world. JsInterop and JSNI are the low-level tools of GWT and allow you to access any JavaScript API be it a browser API or a third party JS framework / library.
For accessing the DOM you can use GWT's Element classes which are implemented using JSNI. Its a thin layer with some adjustments to be cross browser compatible. Since it tries to be cross browser compatible you won't find the newest JS Element APIs here. If you need newer browser features then you either have to use JSNI / JsInterop yourself of use the Elemental library. However as you noted Elemental is based on WebKit so some things simply won't work in all browser. Its up to you to figure out if its safe to use some Elemental APIs based on your decision which browsers you want to support in your app. With GWT 3 or so there will be Elemental 2.0 which will be implemented using JsInterop and will be based on html5index.org. So it won't be webkit specific anymore.
The widget system of GWT is build on top of GWT's Element API and is designed in a way that makes it impossible to produce memory leaks in older browsers (below IE 10) because of circular dependencies between DOM elements and JavaScript event handlers. Most widgets GWT provides are very simple wrappers around HTML elements like <input> and such. There are a few more complex widgets but generally the UI widget set of GWT is just a starting point. For complex apps you will quickly build your own widgets or look at third party UI libraries or even use some shiny webcomponents.
One thing to keep in mind though is that GWT 3.x will have a different compiler than GWT 2.x. Basically GWT 3.x will transform your Java classes into ES6 compatible JavaScript classes which then will optimized by Google Closure compiler. GWT 3.x will also not support some core features of GWT 2.x which means quite some SDK code of GWT needs to be rewritten to be useable with GWT 3. But that is only an issue for existing GWT apps that are based on GWT 2.x. If you start a new app with GWT 3 then you obviously don't have that issue. If you start a GWT 2.x app now then just stay away from GWT-RPC as its something that most likely won't make it to GWT 3, but we will see.
-- J.
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment