Start of Content Area

Background documentation Lead Selection and Node Selection Locate the document in its SAP Library structure

Exactly one element of the node collection is highlighted as the lead selection. The lead selection of a context node points to either a single selected node element (value of the lead selection = number of the selected node element) or it has the value of constants IWDNode.NO_SELECTION, if no node element is selected.

The following facts are connected to lead selection:

·        In the controller code, special generic or generated interface methods can be used to access the lead selection of a node as well as its position: IWDNodeElement IWDNode.getCurrentElement(),
int IWDNode.getLeadSelection()
.

·        The user interface elements can be bound to the attributes of this element.

·        The content of the child nodes depends on the lead selection of the parent node.

In addition to the lead selection (a maximum of a single node element), any number of subsets of the node collection can be distinguished that are identified as node selection. The cardinality of the selection is specified using the selectionproperty, which you can define in the SAP NetWeaver Developer Studio. The cardinality of the subset of node elements that can be selected is usually 0..1, that is, a maximum of one node element can be selected. In general, the node selection can consist of any subset of all node elements that are available in a node. If several node elements can be selected, this is know as multiple selection (selection=0..n or 1..n).

Lead selection and node selection are independent of each other. This means that the lead selection can also point to a node element that does not belong to the node selection.

Data binding between UI element properties and context elements at design time includes the information that is specified using the node selection and lead selection at runtime. For example, selected rows in a table represent the node selection of the node that is bound to the table. Selecting or deselecting an element in the table adds or deletes the corresponding element to or from the node collection.

The possible values of the selection property depend on the cardinality of the node collection itself:

selection property

Required cardinality of the node collection

Short description

0..1

Any cardinality

Lead selection can be empty. Multiple selection is not possible.

1..1

Any cardinality

As the node selection has to contain exactly one element, the lead selection is always set (provided the node is not empty). Multiple selection is not possible.

0..n

0..n, 1..n only

Multiple selection of elements is possible. The lead selection can be empty.

1..n

1..n only

Multiple selection of elements is possible. The lead selection is set automatically (provided the node is not empty).

 

The Web Dynpro runtime environment saves the node selection usually without changing it. The only exception occurs as soon as at least one node element is added to an empty node collection. If the selection property is 1..1 or 1..n, then the corresponding context node has to refer to an element to meet the definition of the selection property. In this case, the node element always forms the lead selection with the index 0.

An additional property that affects the lead selection of a context node is initializeLeadSelection (true or false). It behaves similarly to node selections of type 1..1 or 1..n.

·        initializeLeadSelection= true: The lead selection automatically points to the node element at position 0, after at least one node element was added to a node collection that was previously empty (for example, by calling the bind or addElement methods). If the node selection’s cardinality permits it, the lead selection can subsequently be reset using setLeadSelection(NO_SELECTION).

·        initializeLeadSelection= false: The lead selection is not automatically initialized unless the node selection’s cardinality requires it.

  

  

 

End of Content Area