Hi all,

(As mentioned on the following post:
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/b7c280baf2375841#
)

With the latest versions of GWT you don't have to use any other
libraries.

GWT now comes with something known as Javascript Overlays that you can
utilise to convert JSON into Objects.

See here:

http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsOverlay.html

Also I have made a bit of a discussion on my blog here:

http://eggsylife.co.uk/2010/04/22/gwt-2-jsonp-and-javascript-overlays-with-jsonprequestbuilder/

Hope this helps,

Eggsy

On Jul 6, 1:44 pm, André Moraes <[email protected]> wrote:
> I don't think that the Gson project can be used as a GWT module.
>
> Looks like it is for pure java development, not GWT development.
>
> Take a look at:http://code.google.com/p/piriti/
>
> <http://code.google.com/p/piriti/>This project is a GWT library that provide
> JSON and XML facilities.
>
> On Tue, Jul 6, 2010 at 5:22 AM, Ahmed Shoeib
> <[email protected]>wrote:
>
>
>
> > i face this problem
> > how i can fix it
>
> > the problem
>
> > /AdminPanel.java'
> >         [ERROR] Line 139: No source code is available for type
> > com.google.gson.Gson; did you forget to inherit a required module?
>
> > Thanks,
> > ahmed shoeib
>
> > On Jul 5, 9:33 pm, André Moraes <[email protected]> wrote:
> > > The response comes async.
>
> > > When the response from the server arrives at the client the method
> > > onResponseReceived in the RequestCallback object is called, if an
> > > error hapens the the onErrormethod is called.
>
> > > The RequestCallback object is the second parameter in the sendRequest
> > > function call.
>
> > >                                 public void onResponseReceived(Request
> > > request, Response response)
> > > {
> > >                                         if (response.getStatusCode()
> > > == 200 || response.getStatusCode()
> > > == 304)
> > >                                         {
> > >                                                 JavaScriptObject
> > > responseData =
> > > JsonHelper.stringToJso(response.getText()).cast());
> > >             // use the response
> > >                                         }
> > >                                         else
> > >                                         {
> > >             // invalid response
> > >                                         }
> > >                                 }
> > >                                 @Override
> > >                                 public void onError(Request request,
> > > Throwable exception) {
> > >                                         // error on the resquest
> > >                                 }
> > >                         });
>
> > > On 5 jul, 15:01, Ahmed Shoeib <[email protected]> wrote:
>
> > > > you told me how to send request from client to server
>
> > > > now i want how yo get data from server to use it in client
>
> > > > and the data in json
>
> > > > On Jul 5, 8:12 pm, André Moraes <[email protected]> wrote:
>
> > > > > This code is quite simple
>
> > > > > The line:
>
> > > > >  re = rb.sendRequest("jsonrpc-call=" + JsonHelper.jsoToString(call),
> > > > > new RequestCallback()
>
> > > > > prepare a AJAX call to the server and make your javascript object to
> > a
> > > > > string using JsonHelper.jsoToString.
> > > > > In ther server the json-string will be accessible by the parameter
> > > > > "jsonrpc-call".
>
> > > > > The line:
>
> > > > >                                         if (response.getStatusCode()
> > > > > == 200 || response.getStatusCode()
> > > > > == 304)
> > > > >                                         {
> > > > >                                                 JavaScriptObject
> > > > > responseData =
> > > > > JsonHelper.stringToJso(response.getText()).cast());
> > > > >             // use the response
> > > > >                                         }
>
> > > > > get the response wrote by the server and make i availabe as a
> > > > > JavaScriptObject.
>
> > > > > You can use the JSONObject class to populate and read a
> > > > > JavaScriptObject.
>
> > > > > You can read more about JSON + GWT at:
>
> >http://code.google.com/intl/webtoolkit/webtoolkit/doc/latest/DevGuide...
> > > > > andhttp://
> > code.google.com/intl/webtoolkit/webtoolkit/articles/using_gwt_...
> > > > > On 5 jul, 12:50, Ahmed Shoeib <[email protected]> wrote:
>
> > > > > > i want a simple example to describe it
> > > > > > cause i need it as soon as possible
>
> > > > > > On Jul 5, 6:18 pm, André Moraes <[email protected]> wrote:
>
> > > > > > >                         re = rb.sendRequest("jsonrpc-call=" +
> > JsonHelper.jsoToString(call),
> > > > > > > new RequestCallback() {
>
> > > > > > >                                 @Override
> > > > > > >                                 public void
> > onResponseReceived(Request request, Response response)
> > > > > > > {
> > > > > > >                                         if
> > (response.getStatusCode() == 200 || response.getStatusCode()
> > > > > > > == 304)
> > > > > > >                                         {
> > > > > > >                                                 JavaScriptObject
> > responseData =
> > > > > > > JsonHelper.stringToJso(response.getText()).cast());
> > > > > > >             // use the response
> > > > > > >                                         }
> > > > > > >                                         else
> > > > > > >                                         {
> > > > > > >             // invalid response
> > > > > > >                                         }
> > > > > > >                                 }
>
> > > > > > >                                 @Override
> > > > > > >                                 public void onError(Request
> > request, Throwable exception) {
> > > > > > >                                         // error on the resquest
> > > > > > >                                 }
> > > > > > >                         });
>
> > > > > > > public class JsonHelper {
>
> > > > > > >         public static String jsoToString(JavaScriptObject jso) {
> > > > > > >                 if (isJsonLibraryDefined()) {
> > > > > > >                         return _jsoToString(jso);
> > > > > > >                 } else {
> > > > > > >                         return new JSONObject(jso).toString();
> > > > > > >                 }
> > > > > > >         }
>
> > > > > > >         public static JavaScriptObject stringToJso(String value)
> > {
> > > > > > >                 if (isJsonLibraryDefined()) {
> > > > > > >                         return _stringToJso(value);
> > > > > > >                 } else {
> > > > > > >                         return _stringToJsoEval(value);
> > > > > > >                 }
> > > > > > >         }
>
> > > > > > >         public static native String _jsoToString(JavaScriptObject
> > jso) /*-{
> > > > > > >                 return JSON.stringify(jso);
> > > > > > >         }-*/;
>
> > > > > > >         public static native JavaScriptObject _stringToJso(String
> > string) /*-
> > > > > > > {
> > > > > > >                 return JSON.parse(string);
> > > > > > >         }-*/;
>
> > > > > > >         public static native JavaScriptObject
> > _stringToJsoEval(String
> > > > > > > string) /*-{
> > > > > > >                 return eval("(" + string + ")");
> > > > > > >         }-*/;
>
> > > > > > >         public static native boolean isJsonLibraryDefined() /*-{
> > > > > > >                 return typeof(JSON) != 'undefined'
> > > > > > >                         && typeof(JSON.parse) != 'undefined'
> > > > > > >                         && typeof(JSON.stringify) != 'undefined';
> > > > > > >         }-*/;
>
> > > > > > > }
>
> > > > > > > The JsonHelper class handle the conversion to and from JSON.
>
> > > > > > > If possible use the json.org javascript library that implements
> > the
> > > > > > > functions JSON.parse / JSON.stringify
>
> > > > > > > I am currently writing a project that encapsulates that library
> > and
> > > > > > > make it more easier to use than this JsonHelper class.
>
> > > > > > > When i release it in google-code I let you know.
>
> > > > > > > Hope it helps.
>
> > > > > > > On 5 jul, 09:01, Ahmed Shoeib <[email protected]>
> > wrote:
>
> > > > > > > > Dear Friends ,
>
> > > > > > > > i face a problem when trying to send and receive json object
> > between
> > > > > > > > client and server in GWT application
>
> > > > > > > > so i want a simple example that show me how to do this
>
> > > > > > > > Thanks,
> > > > > > > > ahmed shoeib
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<google-web-toolkit%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-web-toolkit?hl=en.
>
> --
> André Moraes
> Analista de Desenvolvimento de Sistemas
> [email protected]http://andredevchannel.blogspot.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to