tags:

views:

93

answers:

1

Sorry, this is a very basic question, as we are just getting started with exploring GWT.

We would like to know if it's easy and possible to get GWT to "output" XML, JSON and regular HTML. I would like to know this because ideally we would port parts of our backends over slowly, and it would be nice to drop in GWT in place of AJAX wherever we need it during the transition period.

Places that we would like to be able to use:

1) We have a pure XML page that we return to our client (mobile) app and right now this is handled through Spring MVC with a nice template. What's the best replacement for this?

2) We have a regular AJAX page that makes async requests and expects replies in JSON. Can we easily replace this backend?

3) We have some regular webpages where we use templates to output them, and we would like to first switch them over in the simplest possible way, without converting them to the regular GWT UI framework.

Thanks!

A: 

Do you mean, "is it possible to get GWT to accept XML and JSON"? GWT is a framework for writing dynamic JavaScript, not static data formats like XML and JSON.

If that is your question, then yes, it's very easy for GWT to accept JSON data, and slightly harder but still possible to accept XML.

For JSON, you'll want to look into JavaScript Overlay Types. And this tutorial may be helpful in learning how to have GWT read XML-formatted data.

Jason Hall
No, I would like to generate static data (not *accept*). I understand it's a framework designed mostly for outputting dynamic Javascript, but I am wondering if it's possible to output XML/JSON/templated HTML in the same project. I describe the exact cases in my post. One idea that I know people have done is GWT-Spring integration http://oktech.hu/blog/2009/07/spring-gwt-integration-with-ease.html http://code.google.com/p/spring4gwt/ http://pgt.de/2009/07/17/non-invasive-gwt-and-spring-integration-reloaded/
Artem
Yes, it's absolutely possible to have your GWT server produce XML/JSON/HTML output, but this is hardly a GWT question. The server that serves the GWT JS and answers GWT-RPC requests can also have another `HttpServlet` to do anything a normal servlet can (because they *are* normal servlets).
Jason Hall