All,
First off, thanks to all for responding to my previous questions so quickly.
So I have a DataSource, using a custom data format, with an overridden transformResponse() method that basically looks like this:
And the DataSource was configured with fields similar to:
I am positive the json parsing works as expected. Fields with names matching "field1" and "field2" are being set on each Record. However, when this method exits, the ListGrid this DataSource is attached to does not show any records.
Any thoughts here? Am I doing something fundamentally wrong in transformResponse()?
Thanks in advance,
Justin
First off, thanks to all for responding to my previous questions so quickly.
So I have a DataSource, using a custom data format, with an overridden transformResponse() method that basically looks like this:
Code:
protected void transformResponse(DSResponse resp, DSRequest req, Object data) { String str = (String) resp.getData(); Collection<Record> recs = new LinkedList<Record>(); JSONArray jsonArr = JSONParser.parse(str).isArray(); for(int i = 0; i < jsonArr.size(); ++i) { Record rec = new Record(); //do some json parsing... recs.add(rec); } resp.setData(recs.toArray(new Record[0])); super.transformResponse(resp, req, data); }
Code:
DataSourceTextField field1 = new DataSourceTextField("field1", "Field 1"); DataSourceTextField field2 = new DataSourceTextField("field2", "Field 2"); field1.setPrimaryKey(true); DataSource ds = new MyDataSource(); ds.setFields(field1, field2);
Any thoughts here? Am I doing something fundamentally wrong in transformResponse()?
Thanks in advance,
Justin