PDA

View Full Version : [FIXED] [1.2.3] BaseTreeLoader setReuseLoadConfig method does not work



rwinkle
3 Mar 2009, 12:58 PM
The problem I am having is when reloading a TreeTable I want to reuse the last loadConfig value. The BaseLoader class allows you to do this but the BaseTreeLoader class will not since the overloaded load() method does not use the lastConfig or reuseConfig fields.

The steps to reproduce are:
Create an instance of the BaseTreeLoader
Set the reuseConfig field of BaseTreeLoader to true by calling the setReuseLoadConfig(true)
Bind the BaseTreeLoader instance to a TreeStore
Execute the load(Object) method on the BaseTreeLoader instance
Execute the load() method on the BaseTreeLoader instanceOutcome: You will receive the root results instead of the last results.

The lastConfig value is getting set in the parent BaseLoader class when calling load(Object), but load() just executes load(null) instead of checking the lastConfig field. The lastConfig field also exists in the BaseTreeLoader class and is not referenced at all. It can be removed.

rwinkle
3 Mar 2009, 1:42 PM
I am using IE 6 sp2 and FF 3.0.6 on Windows XP sp2
Here's the code to reproduce:



import java.util.ArrayList;
import java.util.List;

import com.extjs.gxt.ui.client.binder.TreeTableBinder;
import com.extjs.gxt.ui.client.data.BaseTreeLoader;
import com.extjs.gxt.ui.client.data.BaseTreeModel;
import com.extjs.gxt.ui.client.data.RpcProxy;
import com.extjs.gxt.ui.client.data.TreeModel;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.treetable.TreeTable;
import com.extjs.gxt.ui.client.widget.treetable.TreeTableColumn;
import com.extjs.gxt.ui.client.widget.treetable.TreeTableColumnModel;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;

public class Test implements EntryPoint {

public void onModuleLoad() {

List<TreeTableColumn> columns = new ArrayList<TreeTableColumn>();
TreeTableColumn column1 = new TreeTableColumn("name", "Name");
columns.add(column1);
TreeTableColumnModel columnModel = new TreeTableColumnModel(columns);

TreeTable treeTable = new TreeTable(columnModel);
RpcProxy<TreeModel, List<TreeModel>> proxy = new RpcProxy<TreeModel, List<TreeModel>>(){

@Override
protected void load(TreeModel loadConfig, AsyncCallback<List<TreeModel>> callback) {
// TODO Auto-generated method stub

BaseTreeModel<TreeModel> data1 = new BaseTreeModel<TreeModel>();
List<TreeModel> models = new ArrayList();
if(loadConfig == null){
data1.set("name", "root");

models.add(data1);
callback.onSuccess(models);
}
else{
BaseTreeModel<TreeModel> data2 = new BaseTreeModel<TreeModel>();
data1.set("name", "child1");
data2.set("name", "child2");

models.add(data1);
models.add(data2);
callback.onSuccess(models);
}
}

};
final BaseTreeLoader<TreeModel> loader = new BaseTreeLoader<TreeModel>(proxy){

@Override
public boolean hasChildren(TreeModel parent) {
return true;
}

};
TreeStore<TreeModel> store = new TreeStore<TreeModel>(loader);
TreeTableBinder<TreeModel> bind = new TreeTableBinder<TreeModel>(treeTable, store);

loader.load();

Button refresh = new Button("Refresh");
refresh.addSelectionListener(new SelectionListener<ComponentEvent>(){

@Override
public void componentSelected(ComponentEvent ce) {
loader.setReuseLoadConfig(true);
loader.load();
loader.setReuseLoadConfig(false);
}

});

ContentPanel vp = new ContentPanel();
vp.add(treeTable);
vp.addButton(refresh);

RootPanel panel = RootPanel.get();
panel.add(vp);

}

}

sven
6 Apr 2009, 2:53 PM
Fixed in SVN.