You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Emmanouil Batsis (Manos)" <ma...@abiss.gr> on 2011/12/09 14:30:05 UTC

How to render a Tree with a preselected node?

Looking around the APIs and all, but haven't figured out how to have a 
LabelTree rendered with the tree expanded properly to point to a 
preselected node.

Manos

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


Re: How to render a Tree with a preselected node?

Posted by "Emmanouil Batsis (Manos)" <ma...@abiss.gr>.
On 12/09/2011 03:30 PM, Emmanouil Batsis (Manos) wrote:
>
> Looking around the APIs and all, but haven't figured out how to have a
> LabelTree rendered with the tr

To answer my own email, it's all about

// select the apropriate node, in my case a
// DefaultMutableTreeNode
tree.getTreeState().selectNode(selectedNode, true);

// call a recursive method to
// expand accordingly
expandToNode(selectedNode);

// the method can be something like
private void expandToNode(DefaultMutableTreeNode node) {
	tree.getTreeState().expandNode(node);
	if(!node.isRoot()){
		expandToNode((DefaultMutableTreeNode) node.getParent());
	}
}


I still need to figure out how to scroll into-view though, I've wrapped 
the trees into fixed-height divs.

Manos

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