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
TestDS.java
test.data.xml
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:
I don't get this in my real application though.
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(); } }
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); } }
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>
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.
Comment