Re: conversion to JavaScriptObject fails with cross site communication

2009-07-29 Thread Adam T

Hi Dale,

Could be a couple of things...

1) Your asBasicComputerInfo() method takes a variable jso and you
try and return a reference to a variable json - though maybe that's
just a typo in your message?

2) Your JSON response from server doesn't appear to be an array, so
ignoring any potential typo above, your asBasicComputerInfo() could be
failing when trying to cast a simple JavaScriptObject into a JsArray
- I'd suggest either returning an array from the server, or altering
your code so you don't use a JsArray.

Also, the data in your JSON is all strings, therefore methods like
public final native int RAM() will possibly fail later in your code -
you could create a new method in the BasicComputerInfo class that does
the conversion for you, e.g. public int getRAM(){Integer.parseInt(RAM
());} and change RAM() to return the String in the JSON.

Hope some of that helps!

//Adam

On 28 Juli, 23:57, dale fortiscont...@gmail.com wrote:
 I am creating my first GWT app and have hit a snag. I suspect that the
 problem is one things below. I can see in the server logs that the
 server returns ok.

    This is the method that fails, there is no error ... that I can
 see :)
           private final native JsArrayBasicComputerInfo asBasicComputerInfo
 (JavaScriptObject jso) /*-{
             return json;
           }-*/;

 I am calling it in the handleJsonResonse  method and execution never
 makes it to the UpdateDetailPanel Method.

           public void handleJsonResponse(JavaScriptObject jso) {
                     if (jso == null) {
                       displayError(Couldn't retrieve JSON);
                       return;
                     }

                     updateDetailPanel(asBasicComputerInfo (jso));//--After 
 the
 breakpoint here it never gets to updateDetailPanel

                   }

 This is the response from the server looks like this when I get it
 from a browser.

 callback0(
 {
 LastBootTime: 7/27/2009 8:46:25 AM,
 UserName: aUser,
 OS: xp,
 OSVersion: 5.1.2600,
 BuildDate: 5/6/2008 3:18:06 PM,
 RAM: 1063329792,
 HDCapasity: 2676800,
 HDFree: 7487799296,
 NumProcessors: 1,
 PowerState: Unknown,
 Site: NA,
 Office: NA,
 IPAddress: NA,
 IPAddress: Dell Inc.,
 Model: OptiPlex GX620}

 );

 here is the BasicComputerInfo Class:

 public class BasicComputerInfo extends JavaScriptObject {

         protected BasicComputerInfo(){}

           // JSNI methods to get stock data.
           public final native String LastBootTime() /*-{ return
 this.LastBootTime; }-*/;
           public final native String UserName() /*-{ return this.UserName; }-
 */;
           public final native String OS() /*-{ return this.OS; }-*/;
           public final native String OSVersion() /*-{ return
 this.OSVersion; }-*/;
           public final native String BuildDate() /*-{ return
 this.BuildDate; }-*/;
           public final native int RAM() /*-{ return this.RAM; }-*/;
           public final native Long HDCapasity() /*-{ return
 this.HDCapasity; }-*/;
           public final native Long HDFree() /*-{ return this.HDFree; }-*/;
           public final native int NumProcessors() /*-{ return
 this.NumProcessors; }-*/;
           public final native String PowerState() /*-{ return
 this.PowerState; }-*/;
           public final native String Site() /*-{ return this.Site; }-*/;
           public final native String Office() /*-{ return this.Office; }-*/;
           public final native String IPAddress() /*-{ return
 this.IPAddress; }-*/;
           public final native String Manufacturer() /*-{ return
 this.Manufacturer; }-*/;
           public final native String Model() /*-{ return this.Model; }-*/;

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



Re: conversion to JavaScriptObject fails with cross site communication

2009-07-29 Thread dale

Thanks Adam,
   You were right about all 3 things, although I'm not sure which
actually fixed it. probably combo of all of them :) .  I changed the
problem method to be:
  private final native BasicComputerInfo asBasicComputerInfo
(JavaScriptObject json) /*-{
return json;
  }-*/;
Fixing the variable to json and making it not return an array.
I also changed everything to strings for now just to see if I can get
it to work.

And it is working!!!
thanks again

dale


On Jul 29, 1:08 am, Adam T adam.t...@gmail.com wrote:
 Hi Dale,

 Could be a couple of things...

 1) Your asBasicComputerInfo() method takes a variable jso and you
 try and return a reference to a variable json - though maybe that's
 just a typo in your message?

 2) Your JSON response from server doesn't appear to be an array, so
 ignoring any potential typo above, your asBasicComputerInfo() could be
 failing when trying to cast a simple JavaScriptObject into a JsArray
 - I'd suggest either returning an array from the server, or altering
 your code so you don't use a JsArray.

 Also, the data in your JSON is all strings, therefore methods like
 public final native int RAM() will possibly fail later in your code -
 you could create a new method in the BasicComputerInfo class that does
 the conversion for you, e.g. public int getRAM(){Integer.parseInt(RAM
 ());} and change RAM() to return the String in the JSON.

 Hope some of that helps!

 //Adam

 On 28 Juli, 23:57, dale fortiscont...@gmail.com wrote:



  I am creating my first GWT app and have hit a snag. I suspect that the
  problem is one things below. I can see in the server logs that the
  server returns ok.

     This is the method that fails, there is no error ... that I can
  see :)
            private final native JsArrayBasicComputerInfo 
  asBasicComputerInfo
  (JavaScriptObject jso) /*-{
              return json;
            }-*/;

  I am calling it in the handleJsonResonse  method and execution never
  makes it to the UpdateDetailPanel Method.

            public void handleJsonResponse(JavaScriptObject jso) {
                      if (jso == null) {
                        displayError(Couldn't retrieve JSON);
                        return;
                      }

                      updateDetailPanel(asBasicComputerInfo (jso));//--After 
  the
  breakpoint here it never gets to updateDetailPanel

                    }

  This is the response from the server looks like this when I get it
  from a browser.

  callback0(
  {
  LastBootTime: 7/27/2009 8:46:25 AM,
  UserName: aUser,
  OS: xp,
  OSVersion: 5.1.2600,
  BuildDate: 5/6/2008 3:18:06 PM,
  RAM: 1063329792,
  HDCapasity: 2676800,
  HDFree: 7487799296,
  NumProcessors: 1,
  PowerState: Unknown,
  Site: NA,
  Office: NA,
  IPAddress: NA,
  IPAddress: Dell Inc.,
  Model: OptiPlex GX620}

  );

  here is the BasicComputerInfo Class:

  public class BasicComputerInfo extends JavaScriptObject {

          protected BasicComputerInfo(){}

            // JSNI methods to get stock data.
            public final native String LastBootTime() /*-{ return
  this.LastBootTime; }-*/;
            public final native String UserName() /*-{ return this.UserName; 
  }-
  */;
            public final native String OS() /*-{ return this.OS; }-*/;
            public final native String OSVersion() /*-{ return
  this.OSVersion; }-*/;
            public final native String BuildDate() /*-{ return
  this.BuildDate; }-*/;
            public final native int RAM() /*-{ return this.RAM; }-*/;
            public final native Long HDCapasity() /*-{ return
  this.HDCapasity; }-*/;
            public final native Long HDFree() /*-{ return this.HDFree; }-*/;
            public final native int NumProcessors() /*-{ return
  this.NumProcessors; }-*/;
            public final native String PowerState() /*-{ return
  this.PowerState; }-*/;
            public final native String Site() /*-{ return this.Site; }-*/;
            public final native String Office() /*-{ return this.Office; }-*/;
            public final native String IPAddress() /*-{ return
  this.IPAddress; }-*/;
            public final native String Manufacturer() /*-{ return
  this.Manufacturer; }-*/;
            public final native String Model() /*-{ return this.Model; }-*/;

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



conversion to JavaScriptObject fails with cross site communication

2009-07-28 Thread dale

I am creating my first GWT app and have hit a snag. I suspect that the
problem is one things below. I can see in the server logs that the
server returns ok.

   This is the method that fails, there is no error ... that I can
see :)
  private final native JsArrayBasicComputerInfo asBasicComputerInfo
(JavaScriptObject jso) /*-{
return json;
  }-*/;

I am calling it in the handleJsonResonse  method and execution never
makes it to the UpdateDetailPanel Method.

  public void handleJsonResponse(JavaScriptObject jso) {
if (jso == null) {
  displayError(Couldn't retrieve JSON);
  return;
}

updateDetailPanel(asBasicComputerInfo (jso));//--After the
breakpoint here it never gets to updateDetailPanel

  }

This is the response from the server looks like this when I get it
from a browser.

callback0(
{
LastBootTime: 7/27/2009 8:46:25 AM,
UserName: aUser,
OS: xp,
OSVersion: 5.1.2600,
BuildDate: 5/6/2008 3:18:06 PM,
RAM: 1063329792,
HDCapasity: 2676800,
HDFree: 7487799296,
NumProcessors: 1,
PowerState: Unknown,
Site: NA,
Office: NA,
IPAddress: NA,
IPAddress: Dell Inc.,
Model: OptiPlex GX620
}
);

here is the BasicComputerInfo Class:

public class BasicComputerInfo extends JavaScriptObject {

protected BasicComputerInfo(){}

  // JSNI methods to get stock data.
  public final native String LastBootTime() /*-{ return
this.LastBootTime; }-*/;
  public final native String UserName() /*-{ return this.UserName; }-
*/;
  public final native String OS() /*-{ return this.OS; }-*/;
  public final native String OSVersion() /*-{ return
this.OSVersion; }-*/;
  public final native String BuildDate() /*-{ return
this.BuildDate; }-*/;
  public final native int RAM() /*-{ return this.RAM; }-*/;
  public final native Long HDCapasity() /*-{ return
this.HDCapasity; }-*/;
  public final native Long HDFree() /*-{ return this.HDFree; }-*/;
  public final native int NumProcessors() /*-{ return
this.NumProcessors; }-*/;
  public final native String PowerState() /*-{ return
this.PowerState; }-*/;
  public final native String Site() /*-{ return this.Site; }-*/;
  public final native String Office() /*-{ return this.Office; }-*/;
  public final native String IPAddress() /*-{ return
this.IPAddress; }-*/;
  public final native String Manufacturer() /*-{ return
this.Manufacturer; }-*/;
  public final native String Model() /*-{ return this.Model; }-*/;
}

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