Announcement

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

    RecordList findAll issue in Chrome (hosted mode)

    I've been having an issue getting RecordList findAll to work in the hosted mode on Chrome browser. I've been seeing the issue since SmartGWT 2.3 / Chrome 9x, and currently I'm running SmartGWT 2.5 LGPL (3/1/2011 nightly build) and Chrome 11x.

    Today I got around to creating a standalone test case to demonstrate the problem.

    TestRecordList.java
    Code:
    package com.dfb.test.client;
    
    import java.util.HashMap;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.data.DSCallback;
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.DSResponse;
    import com.smartgwt.client.data.Record;
    import com.smartgwt.client.data.RecordList;
    import com.smartgwt.client.widgets.Label;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class TestRecordList implements EntryPoint {
    
        public void onModuleLoad() {
            
            VLayout mainLayout = new VLayout();
                    
            mainLayout.setWidth100();
            mainLayout.setHeight100();
            
            final Label label = new Label();
            
            final TestDS testDS = TestDS.getInstance();
            
            testDS.fetchData(null, new DSCallback() {
                public void execute(DSResponse response, Object rawData, DSRequest request) {               
                    RecordList testRecordList = response.getDataAsRecordList();
    
                    System.out.println(testRecordList.getLength()); // prints 2
                    
                    HashMap<String, String> hm = new HashMap<String, String>();
    
                    hm.put("record-id",   "1");
                    hm.put("record-type", "type1");
    
                    Record[] matchingRecords = testRecordList.findAll(hm); // returns null in hosted mode on Chrome
          
                    
                    if (matchingRecords == null)
                    {
                        label.setContents("null");
                        System.out.println("matchingRecords is null");
                    }
                    else
                    {
                        label.setContents("" + matchingRecords.length);
                        System.out.println("" + matchingRecords.length);  
                    }      
                    
                }
            });
    
            mainLayout.addMember(label);
    
            mainLayout.draw();
                    
        }
    }
    TestDS.java
    Code:
    package com.dfb.test.client;
    
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.fields.DataSourceTextField;
    
    public class TestDS extends DataSource {
    
        private static TestDS instance = null;
    
        public static TestDS getInstance() {
            if (instance == null) {
                instance = new TestDS("testDS");
            }
            return instance;
        }	
    	
        public TestDS(String id) {
    
            setID(id);
            setRecordXPath("/List/record");
            
            DataSourceTextField recordIdField = new DataSourceTextField("record-id", "Record Id");
            recordIdField.setPrimaryKey(true);
            recordIdField.setRequired(true);
          
            DataSourceTextField recordNameField = new DataSourceTextField("record-name", "Name");
            DataSourceTextField recordTypeField = new DataSourceTextField("record-type", "Type");
            
            setFields(recordIdField, recordNameField, recordTypeField);
    
            setDataURL("ds/test.data.xml");
            setClientOnly(true);
        }
    }
    test.data.xml
    Code:
    <List>
    	<record>
    		<record-id>1</record-id>
    		<record-name>record1</record-name>
    		<record-type>type1</record-type>
    	</record>
    	<record>
    		<record-id>2</record-id>
    		<record-name>record2</record-name>
    		<record-type>type2</record-type>
    	</record>
    </List>
    Issue: In the hosted mode on Chrome, the findAll call always returns null. Whereas on IE and Firefox, I get the matching records back. Surprisingly, in the deployed mode, even Chrome works fine.

    I'm not sure whether this is a SmartGWT / GWT / Chrome issue. Though I have a workaround (use other browsers) for testing, I wanted to report this issue.

    Thanks.

    ==========================

    On a side note, the above code gives me the following exception on second and subsequent runs of the application:

    Code:
    java.lang.IllegalStateException: Cannot change configuration property 'ID' to testDS after the component has been created.
    I don't get this in my real application though.

    #2
    If it's hosted mode Chrome only, it's a core GWT bug (mentioned in the FAQ).

    Comment


      #3
      Yes, it's hosted mode Chrome only. I read the FAQ entry and it makes sense, though I'm already on GWT 2.1. It works fine in the 'compiled' mode, as stated in the FAQ.

      BTW, on the second issue, I'm curious to know the reason behind the IllegalStateException. I was getting that in IE 8 also. Can you help me understand the issue there.

      Thanks for your help.

      Comment

      Working...
      X