Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Bug: Serialization of JavaScriptObject-Array is broken in Chrome

    Hello,

    I'm using SmartGWT 3.1p 2013/01/02 (LGPL) and the RestDataSource (JSON). The Request contains some GWT-Overlay objects. these are not correctly serialized by SmartGWT. The place where sth. goes wrong is isc.JSONEncoder._serialize

    Here is the Code for reproducing it:

    Code:
    	private static class Test extends JavaScriptObject{
    
    		protected Test() {
    		}
    
    		public final native void setData(JsArray data)/*-{
    			this.data = data;
    		}-*/;
    
    	}
    
    	public void onModuleLoad() {
    		Test test = (Test) JavaScriptObject.createObject();
    		JsArray array = (JsArray) JsArray.createArray();
    		array.push(JavaScriptObject.createObject());
    		array.push(JavaScriptObject.createObject());
    		test.setData(array);
    		HTMLPane htmlPane = new HTMLPane();
    		htmlPane.setContents("<h1>SmartGWT</h1>" + com.smartgwt.client.util.JSON.encode(test) + "</br> " +
    				"<h1>GWT</h1>" + new com.google.gwt.json.client.JSONObject(test).toString());
    		htmlPane.draw();
    	}
    The output in the Chrome-Browser is:
    Code:
    Smartgwt
    
    { "data":{ "0":{ }, "1":{ } } }
    
    GWT
    
    {"data":[{},{}]}
    Btw. the bug only appears in the client mode in Chrome.
    Firefox and hosted mode in Chrome are OK

    #2
    I have the same problem in Chrome Version 28.0.1500.71. I'm using SmartGwt 3.0

    I ended up using your workaround

    Code:
    String json = new JSONObject(jsObject).toString();
    instead of

    Code:
    String json = JSON.encode(jsObject);
    any hint on this Isomorphic?

    Comment


      #3
      This is probably the same core GWT bug mentioned in the FAQ. They fixed that one in GWT 2.5.1.

      Comment


        #4
        Still happening

        I've just updated to GWT 2.5.1 and SmartGwt 3.0 and this is still happening in Chrome when running in production mode.

        Attached TestCase project. (I couldn't find guidelines about attaching files, so I just renamed the zip file to java)
        Attached Files

        Comment


          #5
          Aside from updating GWT you should also use the latest patched version of a current release (3.1 or 4.0).

          Also be sure to clear your GWT unitcache and run a GWT compile.

          Comment


            #6
            Solved!

            I did what you told, updated SmartGwt to 4.0 and "mvn clean package", and it's working fine now in DevMode and Production Mode.

            Thanks!

            Comment

            Working...
            X