Former Member

# Cardinality - Singleton - Selection

Hi All,

Can anyone explain me detaily about these -

1.what is cardinality,Singleton and selection.

Regards,

Karthick

10|10000 characters needed characters exceeded

### Related questions

Former Member
Posted on Sep 15, 2005 at 09:09 AM

Hi Karthick,

This is my understanding of the three terms :

Cardinality is the no: of instances (elements) allowed for a node. If you select 1..1 or 1..n, by default there will be an element created for the node.

Singleton decides whether a single instance exists at a time for a node. If you declare a node as singleton, how much ever elements you create for the node, it will access the same element.

Selection decides the no: of elements you can select at a time.

Hope this helps,

Best Regards,

Nibu.

10|10000 characters needed characters exceeded
• Former Member
Posted on Sep 15, 2005 at 09:08 AM

Cardinality: (Possible) number of elements that may be stored in a node.

Selection: (Possible) number of selected elements in a node.

Singleton: If false, every node element of the parent has its own instance of this node.

Or better: Read "Inside Web Dynpro for Java" by Chris Whealy.

Armin

10|10000 characters needed characters exceeded
• Posted on Sep 15, 2005 at 09:22 AM
10|10000 characters needed characters exceeded
• Former Member
Posted on Jun 26, 2009 at 06:00 AM
```Hi Karthick,

Cardinality: The cardinality defines how often a node is to be instantiated at runtime u2013
that is, how many elements of this node are available at runtime.
u25CF 1u20261
Only one element is instantiated.
u25CF 0u20261
At runtime, no more than one element is instantiated, but it is also possible that no
element is instantiated.
u25CF 1u2026n
n elements can be instantiated, but at least one element must be instantiated.
u25CF 0u2026n
The number of instantiated elements of the context node can vary.

Example:
The context node "Vehicle" is used to describe the fleet of a car rental company. It has the
cardinality 1u2026n and is filled from a database table. A number of attributes of this node have a
specific value for each vehicle.

The database table indicates that the company owns three vehicles, each with unique
registration dates and unique license plate numbers. Thus, to display this table in the Web
Dynpro application, 3 elements of the context node Vehicle must be instantiated; the
cardinality of the node must therefore be 0u2026n or 1u2026n. (If the Vehicle node is to be filled with
values in the context of another function u2013 for example, from a table of all currently available
cars u2013 the cardinality 0u2026n should be used since this table could very easily be empty u2013 that
is, if all cars are rented out.)

*The u201CSingletonu201D Property:*

For each customer of a car rental company, the two attributes u201Crented fromu201D and u201Crented tillu201D
are listed in the context. At runtime, the context then contains the additional relevant values:

If each customer has multiple addresses, it may be necessary to include a child node for the
addresses below the Customer child node. In this manner, the data content of a root node
can rapidly become very large if, at runtime, all customers are displayed with all their
addresses for each vehicle of the of the car rental company. _*To limit the content of a context*_
_*node at runtime, the context node can be assigned the u201Csingletonu201D property*. As a result, the_
_elements of the relevant node are instantiated for only one element of the parent node._
_In other words:_Unlike the cardinality of a node, which describes the number of possible elements within the
node, the u201Csingletonu201D property determines whether or not these elements are set for all
elements of the parent node (non-singleton) or for exactly one element of the parent node
(singleton).

The elements of the child node Customer are only available to one element of the parent
node Vehicle and not to all other elements. However, if you want to instantiate the elements
of the Customer node for all vehicles, you must remove the singleton property for the
Customer node.

At runtime, every child node set as a singleton contains the elements for exactly one element
of the parent node. For this purpose, one element from the set of possible elements of the
parent node must be highlighted. This is achieved by initializing lead selection. For each
newly created context node, lead selection is initialized automatically, but this setting can also
be deactivated. However, lead selection must generally be initialized for every context node.
u25CF Using the preset automatic initialization of lead selection:
In this case, the first element of a node is always assigned the lead selection
property.
u25CF Manual initialization of lead selection:
If the automatic initialization was deactivated, the lead selection must be programmed
manually. However, in this case it is possible to assign this property to an element
other than the first element of a node.
For the above example, this means:
The singleton property of the context node Customer specifies that the elements of this node
are only instantiated for one of the three vehicles at runtime u2013 that is, the element that bears
the lead selection. Since the lead selection was initialized automatically, this is the first
element of the Vehicle node, which in this case is the element Red Car. However, it would
also have been possible to manually set lead selection for one of the other two elements (for
example, using an index).```

Edited by: Vinay Kumar Amruth on Jun 26, 2009 8:00 AM

10|10000 characters needed characters exceeded
• Former Member
Posted on Feb 10, 2010 at 09:52 AM

Cardinality - This property of a node determines the minimum and maximum number of elements that can be stored in the node. Cardinality always has 2 value, minimum and maximum. Following are the possible values for Card..

0..1 (Minimum 0, Maximum 1)

0...n (Minimum 0, Maximum n)

1..1 (Minimum 1, Maximum 1)

1..n (Minimum 1, Maximum n)

Singleton - This property of the node defines the relationship between the parent node and child node. All the independent node always has this property set as true by default and can't be changed. A developer can change the Singleton property of a dependent child node only. If this property for a node is set to be false then for ever parent node element there will be one child node instance. Where as if the singleton property is set to be true then it does not matter how many elements are there in the parent node collection, there will always be a single child node instance. The value in the child node can be re populated by writting a funcation called supply funcation.

Selection - How many no of rows in a table can be selected at a time is determined by selection property.

Thanks,

M.D.Sahu

10|10000 characters needed characters exceeded
• Posted on Feb 10, 2010 at 11:14 AM

Hi Karthick,

Above all are currect. I am adding one link for [The Structural Concepts of Web Dynpro Components.|http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a048387a-0901-0010-13ac-87f9eb649381]

Thanks

Arun Jaiswal