GWT and XML – First steps with com.google.gwt.xml
Developing web applications and portals using eclipse, GWT (google web toolkit) and apache tomcat is one of the most effective ways to get your work done: The result will always be a very high-performance AJAX application. To exchange data from the AJAX surface to the tomcat-server, I decided to use the GWT RPC, exchanging XML data structures.
Therefor GWT provides a nice package: com.google.gwt.xml.client.*
com.google.gwt.xml.client.* is a complete toolkit to deal with xml data-structures on the JavaScript clientside in a high perfomant way.
After having importing the needed packages as usual, I wrote some code to create a new XMLDom stucture. But when running the new code, the following error occured:
Line 52: No source code is available for type com.google.gwt.xml.client.Document; did you forget to inherit a required module?
Up to this point I was used to the fact, that eclipse did everything for me; so I had absolutly no idea what to do, since google returned no hints to this problem. I started to study the documentation and the project in detail and found the solution:
To “inherit” the XML module in GWT, you have to add the following line to the gwt.xml:
<inherits name="com.google.gwt.xml.XML" />
The gwt.xml file can be found under your project in the path: <project>/src/<your domain>/<project>.gwt.xml
After adding this line, dealing with XMLs is really simple. I’ll post an article here with examples, as soon as I can get a little time for my blog again.
If you enjoyed this post, make sure you subscribe to my RSS feed!
Hi, nice posts there
thank’s for the interesting information
Hi, courteous posts there
thank’s exchange for the compelling information
Wow =) thanks for the post
Thanks! I was looking for for long time!
Thanks so much for posting this. I have been scratching my head for 3 hours now.
Bravo Eric,
You saved me hours of trouble!
A big Thank you
Wondered if you have any ideas… I want to write some code which deals with XML which could run either in GWT or also in a normal Java JVM. The problem is that the interfaces
com.google.gwt.xml.client.* and
org.w3c.dom.* which I would normally use on the server
are not compatible – the same code cannot implement both…
Any ideas?
Thanks!!
Marc
@Marc,
yes – it is possible. I will provide here a version of a XML Toolbox on this blog shortly, that will be able to work on clientside, as well as on serverside. So you will be able to use a unified interface. Please stay tuned for this update.
Greetings,
Erik
Great! Even any pointers would be appreciated
It’s been driving me crazy trying to get the same xml manipulations working on both a GWT client and a native Java client
I found a solution. Bit of a hack. I create objects GwtDocument, GwtElement, GwtNode etc. each of which wraps the corresponding org.w3c.dom element so it works in native java environment and each of them implements com.google.gwt.xml.client.* and passes all the methods through (I didn’t do all the methods yet but you get the idea). So you can write XML DOM implementation is dual purpose using com.google.gwt.xml.client.impl.* for GWT and these methods for native Java. Hopefully Erik or someone has a better idea which doesn’t involve passing methods one at a time!
https://docs.google.com/leaf?id=0B69os8I-5UosOGViOGVmNGUtMDNkMi00YzYxLTg5NTAtODVhNzFjNmY2Yjdi&hl=en