TreeGrid + RPCDataSource + executeAdd() + firefox = too much recursion

Hi Guys,

My GWT version is 1.6.4 and I am using SmartGWT 1.1.

I am using the GwtRpcDataSource to populate a ListGrid for an administration screen of my app. The tree is populated OK using executeFetch() and I can delete OK using executeRemove(). I am using a modal window to add new items to the tree, then the form is submitted this method on my DataSource is called:

public void add(CaseTypeDto caseTypeDto)
{
  addData(map(caseTypeDto));
}

My map() method transforms the CaseTypeDto to a TreeNode object.

When the item is added my executeAdd() method is called:

@Override
protected void executeAdd(final String requestId, final DSRequest request, final DSResponse response)
{
    JavaScriptObject data = request.getData();
    final TreeNode treeNode = new TreeNode(data);
    final CaseTypeDto caseTypeDto = map(treeNode);
    RpcServiceLocator.getCaseTypeRpcService().createCaseType(caseTypeDto, new AsyncCallback<Long>(){

        @Override
        public void onFailure(Throwable caught)
        {
            response.setStatus (RPCResponse.STATUS_FAILURE);
            processResponse (requestId, response);
        }

        @Override
        public void onSuccess(Long result)
        {
            treeNode.setAttribute(ID, result);
            TreeNode[] nodeList = new TreeNode[]{treeNode};
            response.setData(nodeList);
            processResponse (requestId, response);
        }
    });
}

This map() method transforms the TreeNode to a CaseTypeDto object.

everything works well in hosted mode, my RPC method is called, the new item is created and it is added to the tree.
In IE7, there is no error, the RPC method is called but nothing is added to the tree.
In Firefox the new item is not added to the tree either and FireBug reports this error:

too much recursion
http://localhost:8080/MYAPP/mypackage.Main/sc/modules/ISC_DataBinding.js
Line 51

Any help with this would be much appreciated!

After some searching, it looks like a better approach would be to use DynamicForm.setDataSource() to bind my form to the same datasource that I am using for my TreeGrid.

It looks like a far cleaner solution and will hopefully keep my tree up to date when a new items are created using the DynamicForm.

Fingers crossed :slight_smile: