Announcement

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

    Record.convertToRecordArray

    Hi,
    I've been logging editedRecord before doing setData, and after response.getDate (but still before processResponse) and I've seen that my record is not the same after using response.getData() !

    Code:
    //log editedRecord here
    response.setData(new Record[]{editedRecord});
    //log  response.getData() here
    processResponse(requestId, response);
    I've changed Record.convertToRecordArray() into the following and this solves "the difference". Can anyone explain (why would I 'sometimes' need to go getRef and sometimes not?) and maybe solve this if this is indeed a bug?

    Code:
    public static Record[] convertToRecordArray(JavaScriptObject nativeArray) {
        if (nativeArray == null) {
            return new Record[]{};
        }
        if (JSOHelper.isArray(nativeArray)) {
            JavaScriptObject[] componentsj = JSOHelper.toArray(nativeArray);
            Record[] objects = new Record[componentsj.length];
            for (int i = 0; i < componentsj.length; i++) {
                JavaScriptObject componentJS = componentsj[i];
    
    //change this:
    //Record obj = (Record) RefDataClass.getRef(componentJS);
    //into:
    Record obj = new Record(componentJS);
    
    
                if (obj == null) obj = new Record(componentJS);
                objects[i] = obj;
            }
            return objects;
        } else {
            Record[] ret = new Record[1];
            ret[0] = Record.getOrCreateRef(nativeArray);
            return ret;
        }
    }

    cheers,
    Last edited by levi; 26 Jul 2010, 01:40.

    #2
    This is quite strange. Can you put a breakpoint in the line after

    Record obj = (Record) RefDataClass.getRef(componentJS)

    using the original code and let us know what the value of "obj" is? As you can see from the following line :

    if (obj == null) obj = new Record(componentJS);

    the value assigned to obj is the same as your code. The call to RefDataClass.getRef(componentJS) returns a non-null value only if you're constructing Record objects yourself.

    If this does not help, then you'll need to provide sample code that reproduces the issue.

    Comment


      #3
      Hi,

      editedRecord =
      com.smartgwt.client.data.Record@16ef267
      JavaScript object(6449)


      Record obj = (Record) RefDataClass.getRef(componentJS)
      com.smartgwt.client.data.Record@e96571
      JavaScript object(6283)
      <=== this object is returned

      If I inspect new Record(componentJS) I see =
      com.smartgwt.client.data.Record@1a75945
      JavaScript object(6449)




      ====== another time for the same record:
      editedRecord =
      com.smartgwt.client.data.Record@1b0edcb
      JavaScript object(6514)

      Record obj = (Record) RefDataClass.getRef(componentJS)
      com.smartgwt.client.data.Record@e96571
      JavaScript object(6283)

      inspect new Record(componentJS)
      com.smartgwt.client.data.Record@feaf1e
      JavaScript object(6514)



      In both cases I get the JSObject 6283, where its 6514 that holds the values I want.

      Comment


        #4
        From the information you posted its still not clear what the cause of the issue is. Can you post a standalone testcase?

        Sanjiv

        Comment

        Working...
        X