Threaded View
-
3 Aug 2012 2:18 AM #1
Trees can have "unsynchronized" TreeStores ->NullPointers
Trees can have "unsynchronized" TreeStores ->NullPointers
Hi,
there is a bug in Tree(Panel)s caused by unsynchronized Stores. If a Tree is given a TreeStore it adds handlers to listen to store events. For example an added entry in the store causes the tree to register a new node. Certain events, however, can cause the store and tree to become unsynchronized. Examples are:- Filtering
- Loading store data before giving the store to the tree
- Probably more
If now an update on the store occurs, the tree's onUpdate method is called:
Here the tree assumes that a node corresponding to the updated StoreModel exists. However, due to the two not being completely synched, this may not be the case. In this case findNode(item) return null and the whole thing produces a NullPointerException:Code:protected void onUpdate(StoreUpdateEvent<M> event) { for (M item : event.getItems()) { TreeNode<M> node = findNode(item); if (node.model != item) { node.model = item; } refresh(item); } }
A temporary bugfix is to override the onUpdate method with the following:Code:Caused by: java.lang.NullPointerException at com.sencha.gxt.widget.core.client.tree.Tree$TreeNode.access$1(Tree.java:345) at com.sencha.gxt.widget.core.client.tree.Tree.onUpdate(Tree.java:1864) at com.sencha.gxt.widget.core.client.tree.Tree$Handler.onUpdate(Tree.java:510) at com.sencha.gxt.data.shared.event.StoreUpdateEvent.dispatch(StoreUpdateEvent.java:101) at com.sencha.gxt.data.shared.event.StoreUpdateEvent.dispatch(StoreUpdateEvent.java:1) at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1) at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40) at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193) at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88) at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127) ... 40 more
This causes the missing nodes first to be registered and then "updated".Code:protected void onUpdate(StoreUpdateEvent<M> event) { for (M item : event.getItems()) { TreeNode<M> node = findNode(item); if(null == node) register(item); } super.onUpdate(event); }Last edited by acerberus; 3 Aug 2012 at 2:19 AM. Reason: typo
ReportServer - Open Source Web Reporting
reportserver.datenwerke.net
Success! Looks like we've fixed this one. According to our records the fix was applied for
EXTGWT-2430
in
3.0.3.


Reply With Quote