Announcement

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

    ClassCastException ListGrid

    This code crashes if you call addData(new Record()) followed by getRecords() on a setSaveLocally(true) listGrid. The cast is unneccesarily specific (it would be fine if it was (Record).

    Fix - use ListGridRecord instead.

    Code:
      private static ListGridRecord[] convertToListGridRecordArray(JavaScriptObject nativeArray) {
            if (nativeArray == null) {
                return new ListGridRecord[]{};
            }
            JavaScriptObject[] componentsj = JSOHelper.toArray(nativeArray);
            ListGridRecord[] objects = new ListGridRecord[componentsj.length];
            for (int i = 0; i < componentsj.length; i++) {
                JavaScriptObject componentJS = componentsj[i];
                ListGridRecord obj = (ListGridRecord) RefDataClass.getRef(componentJS);
                if (obj == null) obj = new ListGridRecord(componentJS);
                objects[i] = obj;
            }
            return objects;
        }

    #2
    the code snip was from ListGrid (probably clear to you, but just in case)

    Comment


      #3
      Maybe I'm wrong about the specificity of the cast - however, it would be nice if the method did a type check and correctly converted any Record() to ListGridRecord() - maybe that should be done on addData() instead?

      Comment

      Working...
      X