Hello all,
I am developing a smart gwt client that needs to tap a REST web service (java jersey running locally). Everything works fine for the XML version, but the JSON version just shows an empty data set in the UI. must be an overlook somewhere but I can't figuring it out. any help appreciated!! I tried to step into the smart gwt code and the only thing that seems to happen is that the ds response gets transformed into an undefined type and "Something other than a Java object was returned from JSNI method". I don't see this reported in the dev console (no error) and can only be seen when stepping in the code.
Thanks,
Seb
Server Side XML works fine:
<code>
@GET
@Path("/query")
@Produces("text/html")
public String fetch(@QueryParam("_startRow") int _startRow,
@QueryParam("_endRow") int _endRow,
@QueryParam("_sortBy") String _sortBy,
@QueryParam("dataPageSize") String dataPageSize, @Context UriInfo ui) {
StringBuffer sb = new StringBuffer();
sb.append("<response>");
sb.append("<status>0</status>");
sb.append("<startRow>" + _startRow + "</startRow>");
sb.append("<endRow>" + _endRow + "</endRow>");
sb.append("<totalRows>10000</totalRows>");
sb.append("<data>");
for (int i = _startRow; i <= _endRow; i++) {
sb.append("<record><fundId>" + i + "</fundId><clientId>" + (i / 3)
+ "</clientId><clientName>Client " + i / 3
+ "</clientName><fundName>Fund " + i
+ "</fundName></record>");
}
sb.append("</data>");
sb.append("</response>");
return sb.toString();
}
</code>
Server Side JSON doesn't work??:
<code>
@GET
@Path("/queryjson")
@Produces("text/html")
public String fetchjson(@QueryParam("_startRow") int _startRow,
@QueryParam("_endRow") int _endRow,
@QueryParam("_sortBy") String _sortBy, @Context UriInfo ui) {
StringBuffer sb = new StringBuffer();
sb.append("{response:");
sb.append("{status:0,startRow:0,endRow:49,totalRows:50,data:[");
for (int i = Math.max(0, _startRow); i < Math.min(_endRow, 10000); i++) {
sb.append("{fundId:\"Fund " + i + "\"}");
if (i < Math.min(10000, _endRow) - 1) {
sb.append(",");
}
}
sb.append("]}}");
return sb.toString();
}
</code>
Client Side:
<code>
public Canvas getCanvas() {
RestDataSource fundProfileDS = new RestDataSource();
OperationBinding fetch = new OperationBinding();
fetch.setOperationType(DSOperationType.FETCH);
fetch.setDataProtocol(DSProtocol.GETPARAMS);
fundProfileDS.setOperationBindings(fetch);
fundProfileDS.setFetchDataURL("rest/data/profile/queryjson"); // works fine w/ /query!!!
DataSourceTextField fundIdField = new DataSourceTextField("fundId",
"Fund Id");
fundIdField.setPrimaryKey(Boolean.TRUE);
fundProfileDS.setFields(fundIdField);
System.out.println(fundProfileDS.getJsonRecordXPath());
{
final ListGrid fundProfileGrid = new ListGrid();
fundProfileGrid.setDataSource(fundProfileDS);
ListGridField fundIdGridField = new ListGridField("fundId");
fundProfileGrid.setFields(fundIdGridField);
fundProfileGrid.setSortField(0);
fundProfileGrid.setDataPageSize(50);
fundProfileGrid.setAutoFetchData(Boolean.TRUE);
return fundProfileGrid;
}
}
</code>
I am developing a smart gwt client that needs to tap a REST web service (java jersey running locally). Everything works fine for the XML version, but the JSON version just shows an empty data set in the UI. must be an overlook somewhere but I can't figuring it out. any help appreciated!! I tried to step into the smart gwt code and the only thing that seems to happen is that the ds response gets transformed into an undefined type and "Something other than a Java object was returned from JSNI method". I don't see this reported in the dev console (no error) and can only be seen when stepping in the code.
Thanks,
Seb
Server Side XML works fine:
<code>
@GET
@Path("/query")
@Produces("text/html")
public String fetch(@QueryParam("_startRow") int _startRow,
@QueryParam("_endRow") int _endRow,
@QueryParam("_sortBy") String _sortBy,
@QueryParam("dataPageSize") String dataPageSize, @Context UriInfo ui) {
StringBuffer sb = new StringBuffer();
sb.append("<response>");
sb.append("<status>0</status>");
sb.append("<startRow>" + _startRow + "</startRow>");
sb.append("<endRow>" + _endRow + "</endRow>");
sb.append("<totalRows>10000</totalRows>");
sb.append("<data>");
for (int i = _startRow; i <= _endRow; i++) {
sb.append("<record><fundId>" + i + "</fundId><clientId>" + (i / 3)
+ "</clientId><clientName>Client " + i / 3
+ "</clientName><fundName>Fund " + i
+ "</fundName></record>");
}
sb.append("</data>");
sb.append("</response>");
return sb.toString();
}
</code>
Server Side JSON doesn't work??:
<code>
@GET
@Path("/queryjson")
@Produces("text/html")
public String fetchjson(@QueryParam("_startRow") int _startRow,
@QueryParam("_endRow") int _endRow,
@QueryParam("_sortBy") String _sortBy, @Context UriInfo ui) {
StringBuffer sb = new StringBuffer();
sb.append("{response:");
sb.append("{status:0,startRow:0,endRow:49,totalRows:50,data:[");
for (int i = Math.max(0, _startRow); i < Math.min(_endRow, 10000); i++) {
sb.append("{fundId:\"Fund " + i + "\"}");
if (i < Math.min(10000, _endRow) - 1) {
sb.append(",");
}
}
sb.append("]}}");
return sb.toString();
}
</code>
Client Side:
<code>
public Canvas getCanvas() {
RestDataSource fundProfileDS = new RestDataSource();
OperationBinding fetch = new OperationBinding();
fetch.setOperationType(DSOperationType.FETCH);
fetch.setDataProtocol(DSProtocol.GETPARAMS);
fundProfileDS.setOperationBindings(fetch);
fundProfileDS.setFetchDataURL("rest/data/profile/queryjson"); // works fine w/ /query!!!
DataSourceTextField fundIdField = new DataSourceTextField("fundId",
"Fund Id");
fundIdField.setPrimaryKey(Boolean.TRUE);
fundProfileDS.setFields(fundIdField);
System.out.println(fundProfileDS.getJsonRecordXPath());
{
final ListGrid fundProfileGrid = new ListGrid();
fundProfileGrid.setDataSource(fundProfileDS);
ListGridField fundIdGridField = new ListGridField("fundId");
fundProfileGrid.setFields(fundIdGridField);
fundProfileGrid.setSortField(0);
fundProfileGrid.setDataPageSize(50);
fundProfileGrid.setAutoFetchData(Boolean.TRUE);
return fundProfileGrid;
}
}
</code>
Comment