Erste Schritte mit GWT und XML unter com.google.gwt.xml
Die Entwicklung von Webapplikationen und Portalen mit eclipse, GWT (Google Web Toolkit) und apache tomcat ist einer der effektivsten Wege die es derzeit gibt: Das Ergebnis ist eine hochperformante, schnelle AJAX-Applikation. Um von der AJAX-Oberfläche mit dem tomcat-Server Daten auszutauschen, benutze ich gerne die GWT RPC, über die ich die Daten in XML-Form austausche.
Hierfür gibt es im GWT ein Paket: com.google.gwt.xml.client.*
com.google.gwt.xml.client.* ist ein vollständiges Toolkit um schnell und effektiv auf Clientseite (JavaScript) mit XML Datenströmen umzugehen.
Nachdem ich die notwendigen Pakete wie üblich importiert habe und einige Methoden zur Erstellung einer XML-Struktur geschrieben habe, trat beim Start der Applikation der folgende Fehler auf:
Line 52: No source code is available for type com.google.gwt.xml.client.Document; did you forget to inherit a required module?
Bis zu diesem Punkt war ich gewohnt, daß eclipse alles für mich regelt; so hatte ich keinen Ansatzpunkt, warum dieses Modul nicht korrekt vererbt wurde. So machte ich mich auf eine lange, aber erfolgreiche Suche in der Dokumentation und dem Projekt selbst, da auch google zu diesem Fehler keine Ergebnisse lieferte:
Um das XML-Modul korrekt zu vererben muß in der “gwt.xml” folgende Zeile ergänzt werden:
<inherits name="com.google.gwt.xml.XML" />
Die “gwt.xml” Datei kann unter folgendem Pfad gefunden werden: <project>/src/<your domain>/<project>.gwt.xml
Nachdem ich diese Zeile ergänzt hatte, ist es sehr einfach mit XML-Strukturen umzugehen. Ich werde hierzu noch einen Artikel veröffentlichen, sowie ich wieder etwas mehr Zeit für meinen Blog habe.
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