View Full Version : Updating TreePanel item on manual tree store item change

29 Jun 2009, 8:02 AM
Is there a better way to update a tree item based on the current value in the tree store, than firing the Store.DataChanged event by hand?

The user changes an object using text fields bound to a TreePanel
-> The change is recognized in the store
-> I send the changed object to a webservice which updates the database and returns the updated object

onResponseReceive method in the Callback object:

public void onResponseReceived(Request objRequest, Response objResponse) {
if (objResponse.getStatusCode() != Response.SC_OK) {
Window.alert("There is something wrong");
} else {
String strData = objResponse.getText();

try { ArrayList<ModelData> lstFreshData = null;
lstFreshData = objReader.read(null, strData);

if (lstFreshData.size() > 0) {
ModelData objFresh = (ModelData)lstFreshData.get(0);
ModelData objStored = objStore.findModel("itemid", objFresh.get("itemid"));

if (objStored != null) {
// This doesn't update the TreePanel item
// *** Fire event would be here ***
} catch (Exception objException) {

To get the TreePanel item updated I have to fire the TreeStore update event by hand (at "*** Fire event would be here ***"):

TreeStoreEvent<ModelData> objUpdateEvent = new TreeStoreEvent<ModelData>(new TreeStore<ModelData>());

objTree.getStore().fireEvent(Store.DataChanged, objUpdateEvent);

Is there something I'm doing wrong or is there a better way to update the tree item?

[ExtGWT 2.0 m3]

Thank you. Regards,