I’m sure I must be doing something wrong, but I can’t seem to figure out what is happening here. I have a need to display differing views depending upon if a user clicks on a leaf item in the tree, or if they click on a parent item. The Tree is also backed by a HierarchicalContainer object. I can render the tree correctly, and I can indeed drill down as expected within the tree, but I’m having a hard time determining the content of the item selected.
I’ve used a ValueChangeListener to detect which item in the tree is clicked on, and I CAN see valid property IDs in the event, but the Item itself is always null. For example, this code (purely for information only) is included in the valueChange event handler (I’d never use S.O.P in real code; I’m just trying to find out why the Item is always null here):
Collection ids = mergeTree.getItem(event.getProperty().getValue()).getItemPropertyIds();
for (Object id : ids) {
System.out.println("ID: " + id);
Object name = mergeTree.getItem(event.getProperty().getValue()).getItemProperty(id);
System.out.println("Name: " + name );
}
The output is something like this in the console:
INFO: ID: name
INFO: Name: null
INFO: ID: container
INFO: Name: null
Any tips or hints at what I’m most likely doing wrong?