Announcement

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

    ClassCastException between ListGridRecord and Record

    Hi, I'm using Records as underlying data of a DataSource. This is being used in a ListGrid. (I want to use the same DataSource for any component, not just restrict it to a ListGrid).

    Somewhere in the event pump, this class is being called and this throws the exception at return (ListGridRecord) obj;
    Code:
    public class ListGridRecord extends Record {
    
        public static ListGridRecord getOrCreateRef(JavaScriptObject jsObj) {
            if(jsObj == null) return null;
            RefDataClass obj = RefDataClass.getRef(jsObj);
            if(obj != null) {
                obj.setJsObj(jsObj);
                return (ListGridRecord) obj;
            } else {
                return new ListGridRecord(jsObj);
            }
    My obj really is a Record:
    Code:
    jsObj	JavaScriptObject$  (id=4245)	
    	hostedModeReference	JsValueIE6  (id=4251)	
    		variant	Variant  (id=4252)	
    			booleanData	false	
    			byRefPtr	0	
    			byteData	0	
    			charData	
    			dispatchData	IDispatch  (id=4253)	
    				address	799049232	
    			doubleData	0.0	
    			floatData	0.0	
    			intData	0	
    			longData	0	
    			shortData	0	
    			stringData	null	
    			type	9	
    			unknownData	null	
    obj	Record  (id=4222)	
    	jsObj	JavaScriptObject$  (id=4245)	
    	manager	null

    Shouldn't there be a constructor ListGridRecord(Record c) at that place?


    (version: SmartGWT 1.1 release)


    thx

    #2
    Can you post your code that is causing this?

    Comment


      #3
      Hi Sanjiv,

      Can't really paste all code, but I've bottled it down:

      Code:
      executeFetch(String requestId, DSRequest request, DSResponse response)
      
      ... do servlet call and onSuccess:
      
      
      response.setData((Record[]) data.values().toArray(new Record[data.size()]));
      processResponse(requestId, response);
      data is a Map<String, Record> data= new TreeMap<String, Record>();
      and if I populate it with Record r = new Record();
      then the class cast exception occurs
      If I populate it with Record r = new ListGridRecord();
      then no error occurs, but then I wonder if I can use this datasource on any other non-ListGrid or TreeGrid widget?

      Comment

      Working...
      X