cancel
Showing results for 
Search instead for 
Did you mean: 

Selection Cardinality & setSelected

Former Member
0 Kudos

Hi,

What is selection cardinality?

What is the difference between these2 context node methods

wdContext.node<Context>().setLeadSelection(int);

wdContext.node<Context>().setSelected(int, boolean );

and How does Selection cardinality affects the setSelected property.

Thanks & Regards

Veerabhadram

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

please follow the following links for your first query

[http://help.sap.com/saphelp_nw70/helpdata/EN/f1/94384162316532e10000000a1550b0/frameset.htm]

SetLeadSelection() selects a particular element by the index.This is mainly used to set the default selection of a dropdown, checkbox group, radio button.

setSelected selects(boolean value =true) or unselects(boolean value =false) an element at a paricular index

regards,

pinki

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

Cardinality

========

The cardinality property is composed of a pair of values that control the maximum and minimum number of elements may contain at runtime. The cardinality property may have four possible values: • 0..1 Zero or one • 0..n Zero or more • 1..1 One and only one • 1..n One or more The first part of the cardinality describes the minimum number of element ’s element collection may contain. This value is either zero or one, and is stored as a Boolean value. This value can be obtained at runtime by calling the method node.getNodeInfo().isMandatory(). The second part of the cardinality describes the maximum number of elements ’s element collection may contain. This value is either a 1 or an n (meaning many) and is stored as a Boolean value (false = 1, true = n). This value can be obtained at runtime by calling method node.getNodeInfo().isMultiple(). If has a cardinality of 1..<something>, then it can be assumed that after the context has been initialised, there will be at least one element present in the node collection. This element is known as the default element and cannot be deleted!

If you attempt to perform some action on a node that would violate the constraints of the cardinality, then you will get a runtime exception in the context. E.G., trying to add a second element to a node of cardinality 0..1, or trying to delete the last element from a node of cardinality 1..n.

Thanks

Hazrath

Former Member
0 Kudos

Cited from?

Armin

Former Member
0 Kudos

Hi,

Node Properties at Design Time:

cardinality:Gives the information about total number of elements that the node contains

Selection:It will allow multiple nodeselection.This propert will set up for the tree node.

There are two possible selections.

1.Single node selection2.Multi node selection.

wdContext.node.SetLeadselection(i):Moves the lead selection to the specified element.

and also sets the lead selection to the given index value.

wdContext.node.setSelected(int, boolean 😞This method will allow you to add or remove elements from this selection.

and also Selects or unselects the element at the given index.

Reagrds,

lavanya G

Former Member
0 Kudos

Selection cardinality defines a constraint on the possible selection of a node.

0:1: At most one element can be selected

1:1: Exactly one is selected

0:N: Any number of elements can be selected

1:N: At least one ...

The first two values define a node with single-selection. The second two values define a node with multi-selection.

There a two distinct selections: the lead-selection and the multi-selection. Your first method sets the lead-selection to the element at index #i. The second method adds node element at index #i to the multi-selection (which does not change the lead-selection)

Armin

Former Member
0 Kudos

Hi evereybody,

Thanks for your replies.

I could not understand what multi selection mean. I created an example.

The context defintion as

There is a value node(MonthsOfYear) that contains single value attribute(monthName) as a child.

For context node :MonthOfYear

cardinality : 0..n

selection : 0...1

When I say

wdContext.nodeMonthsOfYear().setSelected(6, true );

I am getting an exception : selection cardinality does not allow multiple selection,

There a two distinct selections: the lead-selection and the multi-selection. Your first method sets the lead-selection to the element at index #i. The second method adds node element at index #i to the multi-selection (which does not change the lead-selection)

So the method setSelected(int,bool) is responsible for multiselection. When do we need multiselection?

Thanks

Veerabhadram

Former Member
0 Kudos

Hi,

wdContext.nodeMonthsOfYear().setSelected(6, true );

I am getting an exception : selection cardinality does not allow multiple selection,

If you go through the properties of the node you will come across one property called selectioncardinality this property the number of selectable at a time.

If i am not wrong for the node you have created "MonthsOfYear"

this has to be changed to 1..n so that multiselection is possible

Regards

Ayyapparaj

Former Member
0 Kudos

Please read again my answer. I talked about "constraints".

If you constraint the selection to "at most one" (0:1), you define the node selection as "single-selection". What do you expect then if you try to add some of its elements to the multi-selection?

Armin

Former Member
0 Kudos

Hi

go to ur context node properties ,then change the property "selection " to 0-n

Then u did not get the exception

Thanks

Hazrath