Former Member

### Concept behind Cardinality, Singleton property?

hi,

will anyone explain me the concept of cardinality, singleton & Initialize lead selection properties of noce. by example... when i need to set singleton /Initialize lead selection property true / fasle for perticular node...

suppose i am having node structure like this ..

CLAIM Node1

CLAIMITEM Node2

EXPENSETYPE Node3 ... Comes under node2

key

value

Claimid attribute.. Comes under node2

Description attribute.. Comes under node2

Amount attribute.. Comes under node2

if Node CLAIMITEM is bind to table on view....having 4 column ,

first as dropdown by index bind to EXPENSETYPE value...

second as inputfield bind to Claimid....

third as inputfield bind to Description....

fourth as inputfield bind to Amount....

table is having multiple rows so Node CLAIMITEM must have cardinality 0...N

what abt others...

jst try to explain me how does it go and why if possible ..

thanks

saurin shah

10|10000 characters needed characters exceeded

• Nov 28, 2008 at 06:23 AM

Hi Saurin,

I can understand that its kind of confusing to start with these kind of concepts. I will try to say out the basic things about these concepts. But to be frank you would be better off reading the articles available on SDN and experimenting on your system.

Cardinality:

Every context node is composed of two values that, taken together, describe the maximum and minimum number of elements the node collection may hold at runtime. Suppose you want to bind the context to a table then naturally you need to go for either 0..n or 1..n coz the table may contain either a minimum of 0/1 rows & a maximum of any number of rows. (The left hand side refers to the minimum number of elements & the right hand side to the maximum number of elements) This is important coz if you set the wrong value it would end up in a runtime error. The 2 possible kind of cardinality errors are:

1) Trying to delete the default element from a node of cardinality 1..<something>

2) Trying to add a second element to a node of cardinality <something>..1

Suppose you want to bind an attribute under your context node to an input field then you need to set the binding as 1..1 as the field can always hold 1 & only 1 value.

Selection:

Suppose you are displaying the data in a table & want the user to be able to select only 1 row at a time then you can leave the default Selection setting of 0..1 as normal. However if you want the user to be able to select more than 1 row then you need to change the Selection property of the context node to 0..n.

A node's element collection can be accessed using a 1-based index value. Exactly one element of the node collection can be marked as the element at 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, if no element is selected, it has the value of the constant IF_WD_CONTEXT_NODE=>NO_SELECTION. The lead selection can be set automatically by the Web Dynpro framework if the context node property Initialize Lead Selection is set to true. In this case, the first element in a collection will automatically be marked as the element at lead selection.

Singleton:

The Singleton property critically affects the relationship between a dependent node and its parent node. Suppose you have a node BOOKINGS which is a subnode of node FLIGHTS. If the BOOKINGS node has its singleton property set to false then for every element in the parent node collection (FLIGHTS) there will be a distinct instance of the child node BOOKINGS. Therefore, if there are n elements in the parent node, then there will be n distinct instances of a non-singleton child node.

If the node BOOKINGS now has its Singleton property set to true (which is the default), it does not matter how many elements are present in the parent node collection (FLIGHTS, in this case). There will only ever be one instance of the child node BOOKINGS, so the BOOKINGS collection will be a singleton at runtime.

Web Dynpro follows the principle of lazy data instantiation. This means that data is only created when it is actually needed. When this principle is applied to the context architecture, it means that unless the program actually needs to look at the data in a child node, the child node will remain unprocessed. Hence, there is no need to hold multiple instances of data the user has not requested. Lazy data instantiation also means that dependent collections are not automatically created for all elements of the parent node. The creation of a collection of the dependent node is delayed to the point when the related element of the parent

Try going these 3 blogs by Thomas Szuecs regarding singleton property. ( [blog1|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4810] [original link is broken] [original link is broken] [original link is broken]; , [blog2|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/5258] [original link is broken] [original link is broken] [original link is broken]; , [blog3|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4810] [original link is broken] [original link is broken] [original link is broken]; )

Regards,

Uday

10|10000 characters needed characters exceeded
• Former Member
Nov 28, 2008 at 06:27 AM

Hi Saurin,