[ 
https://issues.apache.org/jira/browse/WICKET-3449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13015878#comment-13015878
 ] 

Sergey Plevko commented on WICKET-3449:
---------------------------------------

Martin, if you go back to WICKET-2886, you'll see that the problem with 
junction link was not only with ROOT. There was the fix for that issue. 
Unfortunately, that fix doesn't cover current issue. You propose to use 
_nodeChanged()_ method, but it looks like a hot fix. Sure, this way works, but 
it's rather strange to use _nodeChanged()_ only for the case when you add first 
child to the root. I don't doubt this issue must be fixed internally in the 
wicket framework.

I suppose the problem is in 

{code:title=AbstractTree.java|borderStyle=solid}
public final void treeNodesInserted(TreeModelEvent e)
{
              ...
        // parentNode now has children for the first time, so we may need to 
invalidate
        // grandparent so that parentNode's junctionLink gets rebuilt with a 
plus/minus link
        Object grandparentNode = getParentNode(parentNode);
        // not invalidating if the grandparent is a not presented root
        if (!(getParentNode(grandparentNode) == null && isRootLess()))
        {
                invalidateNodeWithChildren(grandparentNode);
        }
        ...
}
{code}

In our case *parentNode* is ROOT and *grandparentNode* is _null_. So 
_invalidateNodeWithChildren()_ does nothing.

> Tree doesn't update correctly
> -----------------------------
>
>                 Key: WICKET-3449
>                 URL: https://issues.apache.org/jira/browse/WICKET-3449
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-core
>    Affects Versions: 1.4.15
>         Environment: tomcat 6.0.26, win 7
>            Reporter: Sergey Plevko
>            Assignee: Martin Grigorov
>         Attachments: 3.jpg, quickStart.zip
>
>
> When we add a first child to the root node junction link (near the root) 
> doesn't appear in the tree. 
> This bug easily can be reproduced with the next piece of code.
> TestPage.html 
> <html xmlns="http://www.w3.org/1999/xhtml"; 
> xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd";>
> <body>
> <table>
>     <tr>        <td>            <div wicket:id="tree"></div>        </td>    
> </tr>
>     <tr>        <td>            <input type="submit" wicket:id="addChild" 
> class="btn btnStd" />        </td>    </tr>
> </table>
> </body>
> </html>
> TestPage.java
> public class TestPage extends WebPage {
>     public TestPage() {
>         final DefaultMutableTreeNode root = new 
> DefaultMutableTreeNode("root");
>         final DefaultTreeModel treeModel = new DefaultTreeModel(root);
>         final BaseTree tree = new LinkTree("tree", treeModel);
>         add(tree);
>         tree.getTreeState().expandNode(root);
>         AjaxLink addButton = new AjaxLink("addChild") {
>             public void onClick(AjaxRequestTarget ajaxRequestTarget) {
>                 DefaultMutableTreeNode child = new 
> DefaultMutableTreeNode("child");
>                 root.add(child); // it doesn't matter how we add this child
>                 treeModel.insertNodeInto(child, root, 0);
>                 tree.updateTree(ajaxRequestTarget);
>             }
>         };
>         add(addButton);
>     }
> }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to