We have adopted the GWT-RPC code for our project, and it works great. I really like it. Here is a fragment of code from our adopted GWT-RPC implementation class :
Code:
service.add(getRecordType(),getValuesAsMap(new ListGridRecord(data)),new AsyncCallback<HashMap>() {
public void onFailure(Throwable caught) {
response.setStatus(RPCResponse.STATUS_FAILURE);
processResponse(requestId,response);
}
public void onSuccess(HashMap result) {
switch(type.getDataSourceType()) {
case GRID:
ListGridRecord[] list = new ListGridRecord[1];
ListGridRecord newRec = new ListGridRecord();
copyValues(result,newRec);
list[0] = newRec;
response.setData(list);
break;
case TREE:
TreeNode[] tree = new TreeNode[1];
TreeNode node = new TreeNode();
copyValues(result,node);
tree[0] = node;
response.setData(tree);
break;
default:
SC.logWarn("unknown datasource type: " + recordType.getDataSourceType());
}
processResponse(requestId,response);
}
});
Code:
ListGridRecord[] list = new ListGridRecord[1]; ListGridRecord newRec = new ListGridRecord(); copyValues(result,newRec); list[0] = newRec; response.setData(list); break;
I wonder if it would be possible to add multiple records in one shot, and have them be added to the grid by creating & returning an array of not just one record, like above, but of several records ? Are there any things to know or be aware of when implementing such a solution ? Would that approach work for the update() function as well ?
Did anyone successfully implement that approach ?
D.
Leave a comment: