I'm using Isomorphic SmartClient/SmartGWT Framework (v9.0p_2013-09-17/Pro Deployment 2013-09-17). This is browser independent.
I'm having a little trouble using a JSON datasource. I think I'm close though - hopefully I'm just missing something easy. The way I have it working right now, as a DataSource (not a RestDataSource), I get the data but the Collections of Strings in the JSON are not parsed as arrays, but rather as a single string. If I change to a RestDataSource, and all other settings stay the same, I get the error "transformResponse(): JSON response text does not appear to be in standard response format."
Details:
I am outputting the json on the server side with Gson. I have a simple
bean with some strings and 2 collections (permissions and roles). An
example JSON output from the server looks like this:
and the Content-Type is set to application/json
This is just what Gson outputs and I verified it on a bunch of places on the net that it's valid JSON and http://jsonviewer.stack.hu/ even interpreted the permissions as multiple, not a single string of "login, someperm".
Here is the code I used to set it up in a SmartGWT widget:
This works, except the detail viewer shows a single permission of "login,someperm" instead of two permissions. I also tried this on a ListGrid and it worked in the same way: it only shows one permission "login,someperm" instead of two.
I then changed all instances of "DataSource" in the code above and replaced it with "RestDataSource" and that gave me:
"WARN:RestDataSource:isc_RestDataSource_2:RestData Souce
transformResponse(): JSON response text does not appear to be in standard response format."
Any ideas what I'm doing wrong? Feels like I'm close - maybe just missing a setting somewhere?
Thanks,
Brian
I'm having a little trouble using a JSON datasource. I think I'm close though - hopefully I'm just missing something easy. The way I have it working right now, as a DataSource (not a RestDataSource), I get the data but the Collections of Strings in the JSON are not parsed as arrays, but rather as a single string. If I change to a RestDataSource, and all other settings stay the same, I get the error "transformResponse(): JSON response text does not appear to be in standard response format."
Details:
I am outputting the json on the server side with Gson. I have a simple
bean with some strings and 2 collections (permissions and roles). An
example JSON output from the server looks like this:
Code:
{
"username": "me",
"permissions": [
"login",
"someperm"
],
"roles": [
"admin"
],
"app": "appname"
}This is just what Gson outputs and I verified it on a bunch of places on the net that it's valid JSON and http://jsonviewer.stack.hu/ even interpreted the permissions as multiple, not a single string of "login, someperm".
Here is the code I used to set it up in a SmartGWT widget:
Code:
DataSource changedDS = new DataSource();
changedDS.setDataFormat(DSDataFormat.JSON);
changedDS.setDataURL(myurl);
OperationBinding getOperation = new OperationBinding();
getOperation.setOperationType(DSOperationType.FETCH);
changedDS.setOperationBindings(getOperation);
changedDS.setUseStrictJSON(false);
DetailViewer viewer = new DetailViewer();
viewer.setDataSource(changedDS);
viewer.setFields(new DetailViewerField("permissions"));
viewer.setAutoFetchData(true);I then changed all instances of "DataSource" in the code above and replaced it with "RestDataSource" and that gave me:
"WARN:RestDataSource:isc_RestDataSource_2:RestData Souce
transformResponse(): JSON response text does not appear to be in standard response format."
Any ideas what I'm doing wrong? Feels like I'm close - maybe just missing a setting somewhere?
Thanks,
Brian