[ https://issues.apache.org/jira/browse/WICKET-3453?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12996384#comment-12996384 ]
Sergey Plevko commented on WICKET-3453: --------------------------------------- Solutions with changing tree.updateTree() to tree.updateTree(target) doesn't work. Generally speaking i don't see a big difference between this methods. > Selection remains after removing collapsed node in the tree. > ------------------------------------------------------------ > > Key: WICKET-3453 > URL: https://issues.apache.org/jira/browse/WICKET-3453 > Project: Wicket > Issue Type: Bug > Components: wicket > Affects Versions: 1.4.5, 1.4.14 > Environment: tomcat 6.0.26, win 7 > Reporter: Sergey Plevko > Assignee: Martin Grigorov > Attachments: quickStart.ZIP > > > If we fire 'node removed event' in the tree, it deselects only node which is > currently shown (not under collapsed parent). > There are two use cases which show correct and incorrect behavior. > Step 1: expand ROOT > Step 2: expand SUBTREE > Step 3: select LEAF > Step 4: press 'Print Selection' > Result 4: 'Selected Node: LEAF' > Step 5: press 'Delete SUBTREE' > Step 6: press 'Print Selection' > Result 6: 'Selected Node: --NO SELECTION--' > This behavior is correct. > Step 1: expand ROOT > Step 2: expand SUBTREE > Step 3: select LEAF > Step 4: press 'Print Selection' > Result 4: 'Selected Node: LEAF' > ------------------------------------- > Step 5: collapse SUBTREE > ------------------------------------- > Step 6: press 'Delete SUBTREE' > Step 7: press 'Print Selection' > Result 7: 'Selected Node: LEAF' > 'LEAF' is still selected, but there is no such node in the tree model. > Use the code below to reproduce the bug. > Test.html > <html> > <body> > <div wicket:id="tree"></div> > <input type="button" wicket:id="printSelection" value="Print Selection"> > <input type="button" wicket:id="delete" value="Delete 'SUBTREE'"> > <br>Selected Node: > <b><span wicket:id="selection"></span></b> > </body> > </html> > Test.java > public class Test extends WebPage { > private DefaultMutableTreeNode subTree; > public Test() { > final LinkTree tree = new LinkTree("tree", createTreeModel()); > add(tree); > final Label selection = new Label("selection"); > add(new AjaxLink("printSelection") { > @Override > public void onClick(AjaxRequestTarget target) { > Collection<Object> selectedNodes = > tree.getTreeState().getSelectedNodes(); > String selectionString = "--NO SELECTION--"; > if (selectedNodes.size() > 0) { > selectionString = > selectedNodes.iterator().next().toString(); > } > selection.setDefaultModel(new Model<String>(selectionString)); > target.addComponent(selection); > } > }); > add(new AjaxLink("delete") { > @Override > public void onClick(AjaxRequestTarget target) { > DefaultTreeModel treeModel = (DefaultTreeModel) > tree.getModelObject(); > if(subTree != null) { > treeModel.removeNodeFromParent(subTree); > subTree = null; > } > tree.updateTree(); > } > }); > selection.setOutputMarkupId(true); > add(selection); > } > protected TreeModel createTreeModel() { > DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("ROOT"); > subTree = new DefaultMutableTreeNode("SUBTREE"); > DefaultMutableTreeNode leaf = new DefaultMutableTreeNode("LEAF"); > rootNode.add(subTree); > subTree.add(leaf); > return new DefaultTreeModel(rootNode); > } > } -- This message is automatically generated by JIRA. - For more information on JIRA, see: http://www.atlassian.com/software/jira