You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Аносов А.О." <an...@its.samara.ru> on 2009/10/14 06:55:10 UTC

Wicket LinkTree and TreeModel serialisation

Hi,

I have page with panel (a custom class named TreePanel) that contains 
Wicket LinkTree. LinkTree uses TreeModel instance which is common for 
all pages in application (tree model resides in application class).
When any page that contains TreePanel being serialized, TreeModel also 
seriailzes with page instance. I need to avoid TreeModel serialization. 
I've used LoadableDetachableModel as in following code, but it didn't 
work. Is it possible to avoid this?

public class TreePanel extends Panel
{
    private static final long serialVersionUID = 1L;
   
    private static class DocumentTree extends LinkTree
    {
        private static final long serialVersionUID = 1L;

        public DocumentTree(String id, IModel<TreeModel> model)
        {
            super(id, model);
            getTreeState().expandNode(model.getObject().getRoot());
        }
       
        @Override
        protected void onNodeLinkClicked(Object node, BaseTree tree,
                                         AjaxRequestTarget target)
        {
            TreeModelBean data =
                
(TreeModelBean)((DefaultMutableTreeNode)node).getUserObject();
           
            ((BasePage)getPage()).ajaxRequestReceived(target, data,
                    AjaxEventType.DATA_VIEW_UPDATE);
        }
    }
   
    private LinkTree tree_;
   
    @SuppressWarnings("serial")
    public TreePanel(String id, TreeModel model)
    {
        super(id);
       
        tree_ = new DocumentTree("tree", new 
LoadableDetachableModel<TreeModel>()
        {
            @Override
            protected TreeModel load()
            {
                return MyApp.get().getTreeModel();
            }           
        });
       
        add(tree_);
    }

}

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org