cancel
Showing results for 
Search instead for 
Did you mean: 

Need explanation for cardinality and selection terms at the Context

Former Member
0 Kudos

Hello,

Can someone please explain me in simple words what are the terms "cardinality" and "selection" when building new node at the Context? What do they use for exactly and when to use them?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI,

<b>Cardinality</b> is the property of the node which determines this node is a collection or not and determines wether ao not this node is intialised..

<b>The specification of the cardinality indicates the number of possible node elements. At design time, you can determine the cardinality of a node collection, which provides another way of manipulating the behavior of the context node.</b>

<b>Selection</b> is also a property similar to cardinality for a context Node

<b>Node Selection</b>

Nodes can qualify a specific part of their node collection. For this, the node selection is used

The cardinality of the selection is specified using the selection property, which you can define in the SAP NetWeaver Developer Studio.

One element of the selection is highlighted as the lead selection. The following applies to the lead selection:

The controller code of an application program can access the element of the lead selection with little effort.

The UI 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.

Node selection and lead selection are both node properties that can be bound. Therefore, the UI elements can display and modify this selection.

For example, selected rows in a table represent the selection of the node bound to the table. Selecting or deselecting an element in the table adds or deletes the corresponding element of the node collection

0..1 |Any cardinality| The selection of an element (@ of a lead selection) - can be empty

1..1 | 1..1, 1..n only| The selection of an element (@ of a lead selection) – must contain at least one element.

0..n | 0..n, 1..n only| Multiple selection of elements – it can be empty, one element is specified as the lead selection.

1..n | 1..n only| Multiple selection of elements - one element is specified as the lead selection.

Hope you got a clear picture of cardinality and selection

Regards,

RK

Answers (3)

Answers (3)

Former Member
0 Kudos

HI Roy

I simple terms Cardinality 1-1 is used when that particular node holds only one record at any point of time and 0-N this node need not hold any record and can hold as many it can.

See generally u use cardinality 0-n for a table imagine it holds many records and 1-1 u use when u r submitting some data i.e 1 record at a time to the back end etc..

This ofcourse for a particular scenario i am talking abt.

Hope u can build on this

With Wishes

Krishna Kanth

Former Member
0 Kudos

It is the way by which manipulation of the node is being made possible in webdynpro.If the node as such is considered as a collection then selection is for getting a part of it.Once the lead selection is made true,the element can be accessed easilly by the code at the view controller .

the various values of selection can be

0...1 -indicating selection can be empty.there can be one element as lead selection

1...1-indicating that there should be one element as lead selection

0...n-multiple elements selected.it can be also empty.one element is specified as lead selection

1...n-multiple elements selected .it shouldnt be empty

The lead selection need not point to an element inside selection.it may point to another element also

hope it is clear

Regards

Rohit.R.Krishnan

Former Member
0 Kudos

Hi Roy,

A brief explanation what i understood

First we should know the definition for Context

Context:

The data used in the component or in the view are stored in the context. Read-write access to this data is available using the controllers as a starting point

Structure:

The data from the contexts is managed in a hierarchical structure. Each context has a root node, underneath which the individual data fields (attributes) are stored in a tree structure. You create this tree structure according to the structure of your application.

Each node contains data fields that represent one of the following:

1)An individual instance of an object type

2)A table of instances

The property of a node is defined as Cardinality.Cardinality of a Context Node

When a node is created in the context of a Web Dynpro component, the cardinality of a node is specified. The cardinality defines how often a node is to be instantiated at runtime – that is, how many elements of this node are available at runtime.

· 1…1 Only one element is instantiated.

· 0…1 At runtime, no more than one element is instantiated, but it is also possible that no element is instantiated.

· 1…n n elements can be instantiated, but at least one element must be instantiated.

· 0…n The number of instantiated elements of the context node can vary.

to know more about cardianlity look in to

http://127.0.0.1:3377/help/index.jsp?topic=/com.sap.devmanual.doc.user/7a/787e40417c6d1de10000000a15...

to know more about selection see this URL

http://127.0.0.1:3377/help/index.jsp?topic=%2Fcom.sap.devmanual.doc.user%2F15%2F0d4f21c17c8044af4868...

hope this helped you..

Regards

RK

Former Member
0 Kudos

Dear Venkat,

Thank you for your detailed explanation.

I understood what the cardinality means but still don't understand what the selection means?

And regarding cardinality: If for example I set it to 1..1 does this mean that I can create only one one from this type? If yes, why do I need it? why not use 0...n all the time?

former_member182372
Active Contributor
0 Kudos

Hi Roy,

"selection" means how many elements from node can you select. Try to create node with some attributes and "visualize" it with table. And try to play around with selection. It will be more vivid than any explanations.

Regards, Maxim R.