When tree node is selected the appropriate part of tree is rebuilt,
which also involves recreating the components. So the component on
which you're calling getPage() is no longer in hierarchy, thus the
page returned is null.

-Matej

On 4/8/07, Isaac Weng <[EMAIL PROTECTED]> wrote:
> Hi,
>
>     Similar to ILinkCallback of Tree in wicket-extension, I created a
> callback link which allows me to select a tree node in my custom Link
> component. After the link is clicked, the callback is executed and the
> node is selected. However, after selectNode() runs, getPage() in the
> Link component results in "No Page found for component". Following is a
> brief sample code:
>
> MyTree.html:
>
>     <wicket:panel>
>         <div class="wicket-tree">
>             <div wicket:id="i"><div class="a_">
>                 <span wicket:id="indent"></span><a
> wicket:id="link"><span wicket:id="image"/></a><span wicket:id="myPanel" />
>         </div></div></div>
>     </wicket:panel>
>
> MyTree.java:
>
>     public class MyTree extends DefaultAbstractTree
>     {
>        ...
>
>        protected void populateTreeItem(final WebMarkupContainer item,
> int level)
>        {
>           ...
>
>           final DefaultMutableTreeNode node = (DefaultMutableTreeNode)
> item.getModelObject();
>           add(new MyPanel("myPanel", item.getModelObject(), new
> IMyLinkCallback()
>           {
>              public void onClick(AjaxRequestTarget target)
>              {
>                 getTreeState().selectNode(node,
> !getTreeState().isNodeSelected(node));
>              }
>           });
>        }
>
> MyPanel.html:
>
>     <wicket:panel>
>         <a wicket:id="link"><span wicket:id="outputName"></span></a>
>     </wicket:panel>
>
> MyPanel.java:
>
>     public class MyPanel extends Panel
>     {
>         public MyPanel(String id, Object object, final IMyLinkCallback
> callback)
>         {
>             super(id);
>
>             Link myLink = new Link("link")
>             {
>                 public void onClick()
>                 {
>                     getPage();      // return the Page instance correctly.
>                     callback.onClick(null);
>                     getPage();      // No Page found for component
>                 }
>             };
>
>             DefaultMutableTreeNode node = (DefaultMutableTreeNode) object;
>             myLink.add(new Label("outputName", (String)
> node.getUserObject()));
>             add(myLink);
>         }
>     }
>
> IMyLinkCallback.java:
>
>     public interface IMyLinkCallback extends IClusterable
>     {
>         public void onClick(AjaxRequestTarget target);
>     }
>
>
>
>     The problem appears in both 1.3.0 of April 4, and 1.2.5. Am I doing
> it in a wrong way ?
>
>
> Isaac
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to