-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I have a Tree for which I have written a model ("MyModel") and a node class ("MyNode"). In MyNode, I'm storing some additional information with getter/setter, for example a String in "MyNode.getMyString()".
When someone clicks now on the tree, I can access its items via TreeItem:
@Listen("onSelect =#datasetsTree")
public void onSelectDatasetsTree(Event ev){
LOGGER.info(datasetsTree.getSelectedItem().getLabel());
}
But how can I access now the "MyNode" object behind it, a casting doesn't works?
Thanks for any hints and in general I would like to say Thank You for the excellent help in this forum!
If it's a Tree
you have you can get the selected node by :
// maybe some more casting need to be done.
Set<MyNode> nodes = ((MyModel)tree.getModel()).getSelection();
This is of course true if MyModel
extends AbstractTreeModel
.
Greetz chill.
Hello
event.getTarget() will give you the component on which the event is being triggered. once you have the target you can cast it to your component and call your methods.
Harish.
Asked: 2015-05-06 15:32:33 +0800
Seen: 19 times
Last updated: May 07 '15
Large Tree with dynamic columns
Tree width lost after changing col width on maximized panel
MVVM tree example to show add/insert/delete/move/drag?
Error writing 'checked' on type org.zkoss.zul.Checkbox [closed]
Problem with changing MVVM tree model
zk framework: how to load zul pages from WEB-INF under directory zul
the datasetsTree is Tree class?
chillworld ( 2015-05-07 09:23:26 +0800 )edit