|
Different selection types |
|
Tree component supports two different selection type: SINGLE and MULTIPLE.
SINGLE is the default mode and means that you can not choose more then one item in the tree. Selection is changed every time you click on tree item (branch or leaf).
Multiple mode allows to select any number of tree items(branch or leaf) using Cntrl + MouseClick action. After necessary multiple selection is made you can submit all selected items to the server-side by clicking on any(even on unselected ) tree item.
If TreeBranchSelectedListener or TreeLeafSelectedListener isn't assigned to Tree component then all selected items will be reset after page reloading. If you have at least one listener assigned (TreeBranchSelectedListener or TreeLeafSelectedListener ) then all selected items will be sent to the server-side and Tree selection model will be updated.Selection model will contain all selected items using "0,1,1.." like syntax.
See BaseTreeSelectionModel API documentation for detail of how to get the selected items.
JSP example:
<tree:selectionModel selectionType="MULTIPLE" beanName="multipleSelectionModel" scope="session"/>
Example of selection model:
public class TreeSelectionModelBean extends TreeSelectionModel {
/**
* Constructor - model assembling
*/
public TreeSelectionModelBean() {
super();
this.setSelectionType("MULTIPLE");
}
}
Full functional sample can be found in the test application at "Tree->Tree advanced samples->Advanced features(partII)->Multiple selection mode".