Find the "Tree node object" by that tree node's caption...

Hi all,

Is there a way of finding a Tree node Object by it’s caption…??
Something similar to the following.

Object theNodeObject = myTree.getItemByCaption("Node caption");

Any help is greatly appreciated.
Thanks in advance.


Hi all,

Just did a “dirty trick” & got it solved.
If there’s a better solution, please let me know.
My “dirty solution” is as follows.

    // Id for the caption property
	private static final Object CAPTION_PROPERTY = "caption";

	 * Returns the Node matching to the given caption. 
	 * If nothing is found, returns NULL.
	 * @param caption
	 * @return
	public Object getNodeByCaption(String caption){
		for (Object item : myTree.getItemIds()) {
			Item itm = myTree.getItem(item);
			Property prop = itm.getItemProperty(CAPTION_PROPERTY);
			if (prop.getValue().toString().equalsIgnoreCase(caption)) {
				return item;
		return null;


There is no better general solution, as doing this in the framework would break lazy loading.
The only real alternatives I can think of now are using captions as the tree node IDs, keeping a map from caption to node ID or doing this on the level of a custom data model.