[ 
https://issues.apache.org/jira/browse/WICKET-1922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Igor Vaynberg reassigned WICKET-1922:
-------------------------------------

    Assignee: Matej Knopp

> AbstractTree - setting root to null causes NullPointerException
> ---------------------------------------------------------------
>
>                 Key: WICKET-1922
>                 URL: https://issues.apache.org/jira/browse/WICKET-1922
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.5
>         Environment: JDK 1.6.0_01
>            Reporter: Vlastimil
>            Assignee: Matej Knopp
>
> I have TreeTable with some nodes, perform some filtering of them and update 
> tree model. If result of filtering is nothing (empty Tree) I set 
> setRoot(null) on the tree model. This send treeStructureChanged event to all 
> listeners (to my TreeTable) with parameter TreeModelEvent which is 
> constructed with null TreePath parameter. This cause NullPointerException in 
> AbstractTree (implements TreeModelListener).
> I propose this fix:
> org.apache.wicket.markup.html.tree.AbstractTree
> /**
>        * @see 
> javax.swing.event.TreeModelListener#treeStructureChanged(javax.swing.event.TreeModelEvent)
>        */
>       public final void treeStructureChanged(TreeModelEvent e)
>       {
>                           // empty root
>                           if(e.getTreePath() == null) {
>                       invalidateAll();
>                           } 
>               else {
>                       // get the parent node of changed nodes
>                       TreeNode node = 
> (TreeNode)e.getTreePath().getLastPathComponent();
>                       // has the tree root changed?
>                       if (e.getTreePath().getPathCount() == 1 && 
> node.equals(rootItem.getModelObject()))
>                       {
>                               invalidateAll();
>                       }
>                       else
>                       {
>                               invalidateNodeWithChildren(node);
>                       }
>               }
>       }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to