Home > GWT, Java > GWT and XML – First steps with com.google.gwt.xml

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!

Post to Twitter Tweet This Post

Categories: GWT, Java Tags: , , ,
  1. Mike
    09:38 PM at 09:38 PM | #1

    Hi, nice posts there :-) thank’s for the interesting information

  2. Ceawite
    11:20 AM at 11:20 AM | #2

    Hi, courteous posts there :-) thank’s exchange for the compelling information

  3. 02:29 PM at 02:29 PM | #3

    Wow =) thanks for the post

  4. Arn
    02:24 AM at 02:24 AM | #4

    Thanks! I was looking for for long time!

  5. Manny
    01:16 PM at 01:16 PM | #5

    Thanks so much for posting this. I have been scratching my head for 3 hours now.

  6. Kyriacos Antoniades
    03:45 PM at 03:45 PM | #6

    Bravo Eric,

    You saved me hours of trouble!
    A big Thank you

  7. Marc
    07:53 AM at 07:53 AM | #7

    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

  8. 09:01 AM at 09:01 AM | #8

    @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

  9. Marc
    07:09 PM at 07:09 PM | #9

    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

  10. Marc
    06:03 AM at 06:03 AM | #10

    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

  1. No trackbacks yet.