Putting Constraints on Tree Selection

Hi All,

Is it possible to plug in some selection logic into the tree? I have a requirement to only allow selection of leaf nodes. Additionally, the user is allowed to multi-select sibling leaf nodes.

How is the best way to do this? The Tree control doesn’t have a pluggable selection model.

Not completely sure but I guess if you enable selection then all nodes are selectable, but you can skip the processing for non-leaf nodes. Could be that this requires changes to Tree.java (and VTree.java) code. I’d guess the change is simple, adding a method to server-side code that enables only leaf selection and then code to the client-side that ignores non leaf selections.

As a security / logic check. You should also check on the server-side that if leaf node selection is only allowed, no matter what the client-side sends back to the server-side, it actually is only leaf nodes that client-side has been selecting.

But, this here’s possibly another way to do it: https://vaadin.com/forum/-/message_boards/view_message/131562