You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Oh...@via.com.tw on 2004/12/23 07:08:55 UTC

DefaultTreeModel: nodeStructureChanged + Tree Reloading

Hi All
 
I test the scenario from David.
I found that TreeModel won't hook ModelListener in HtmlTree
because when you try to use DefaultTreeModel to build a TreeModel.
You just do 
DefaultTreeModel treeModel = new DefaultTreeModel(root);
and this construction won't hook any listener.
I think maybe the scenario as follows will work.
 
// Resolve the tree table.
FacesContext facesContext = FacesContext.getCurrentInstance();
VariableResolver vr =
facesContext.getApplication().getVariableResolver();
RoleTreeTable roleTree =
(RoleTreeTable)vr.resolveVariable(facesContext,RoleTreeTable.ROLE_TREE_T
ABLE);
 
//you should hook listener if you want to construct a tree model.
//roleTree.setTreeModel(SecurityApplicationUtils.buildRoleTreeModel());
 
DefaultMutableTreeNode root =
(DefaultMutableTreeNode)roleTree.getTreeModel().getRoot();
//add new node or remove node in root
DefaultMutableTreeNode target = null;//target is the node that will be
added or removed
DefaultMutableTreeNode parent = null;//parent is the parent node of
target
...........
 
 
roleTree.getTreeModel().nodeStructureChanged(parent);

 
 
 
 
 
ohara