Why does GWT's API differ so much from the Javascript one?

69 views
Skip to first unread message

Stephen Buergler

unread,
Nov 11, 2011, 8:53:19 AM11/11/11
to google-we...@googlegroups.com
Wouldn't it be easier to use the interfaces in org.w3c.dom.* or to generate new ones from idl files. The WebIDL spec shows how to translate things to Java, though I am having a tough time finding more information about it.

Thomas Broyer

unread,
Nov 12, 2011, 4:29:17 AM11/12/11
to google-we...@googlegroups.com
Which API do you find "so much different" from the native one? I don't think com.google.gwt.dom.client.* can be less different that the API it's making available to the GWT Java world. Same for com.google.gwt.canvas, com.google.gwt.geolocation, com.google.gwt.media, com.google.gwt.regexp, com.google.gwt.storage, and com.google.gwt.xhr.
Event handling has to be different for various reasons (prevent memory leaks being one of them: http://code.google.com/p/google-web-toolkit/wiki/DomEventsAndMemoryLeaks )

toon...@gmail.com

unread,
Nov 13, 2011, 4:52:12 AM11/13/11
to Google Web Toolkit
Yes but it isn't clear how to share code between the client and server
-- especially in the case the original poster mentioned: org.w3c.dom.*
We were forced to wrap all the org.w3c.dom interfaces in classes that
implement the com.google.gwt.client.xml interfaces.

I understand that GWT can't implement some parts of org.w3c.dom.*
(e.g. namespaces) but rather than introduce a new interface I would
rather have had errors in those cases. The truly best situation would
be if the org.w3c.dom interfaces were defined as extending the
com.google.gwt.client.xml interfaces. But I don't see how that could
be done.

Thomas Broyer

unread,
Nov 13, 2011, 5:14:35 AM11/13/11
to google-we...@googlegroups.com
org.w3c.dom is such a pain to work with, you'd better define your own API that you implement on top of it (or JDOM or dom4j or whatever) on the server-side, and com.google.gwt.xml or com.google.gwt.dom on the client-side. This is exactly what the Wave guys did, and it works pretty well: https://svn.apache.org/repos/asf/incubator/wave/trunk/src/org/waveprotocol/wave/model/document/MutableDocument.java (their implementation is a bit convoluted, as it's layered with IndexedDocument that is necessary for the Operational Transformation operations, but my point is that it's possible and quite easy); it allows for such things like easy iteration: https://svn.apache.org/repos/asf/incubator/wave/trunk/src/org/waveprotocol/wave/model/document/util/DocHelper.java and https://svn.apache.org/repos/asf/incubator/wave/trunk/src/org/waveprotocol/wave/model/document/util/DocIterate.java

Stephen Buergler

unread,
Nov 13, 2011, 7:20:42 AM11/13/11
to google-we...@googlegroups.com
Window.open returns void. Stuff is missing like document fragments. It seems to me like none of this stuff has to be rewritten if it all the interfaces were generated from webidl then the implementations from GWT generators.
Reply all
Reply to author
Forward
0 new messages