Show TOC

Singleton NodeLocate this document in the navigation structure

Use

The singleton property of a context node describes the relationship between a parent node and its child node.

Example

To extend the example in section Node Cardinality , for each customer of the car rental company, the information rented from and rented until are stored. In the context, a child node Customer is introduced, containing the attributes RentFrom and RentTo . At runtime, the context then contains the additional relevant values:

At runtime, the Customer node of the first element of the Vehicle node (the node with the descriptive data for the red car) contains three elements in its turn, one element for each of the three stored rental procedures.

Delimiting the Amount of Subnode Elements

If your context structure is allowed to grow to any hierarchical depth, the number of instances of child nodes can easily grow exponentially. This in turn could have serious consequences for your application's memory consumption. To solve these potential performance issues, you can set the singleton property on every dependent node.

Note

The Singleton property of an independent node is always set to true. You cannot modify this property.

The figure above shows the runtime structure if the Singleton property of node Customer is set to false . Now, for every element in the parent node collection, there will be a distinct instance of the child node Customer .

The most important thing to understand here is that each instance of node Customer is related to the respective element in the parent node collection. Therefore, if there are n elements in the parent node (e.g. three cars), then there will be n distinct instances of a non-singleton child node (e.g. three sets of customer data).

Setting the Singleton Property to True

Having singleton child nodes greatly reduces the amount of memory required for a business application, and means that the Web Dynpro application does not waste time performing unnecessary processing on business data the user has not explicitly requested.

If the node Customer now has its singleton property set to true (which is the default), then irrespective of how many elements are present in the Vehicle parent collection, there will only ever be one instance of the child node Customer .

Maybe, in the example above this would not make too much sense, as the complete customer related rental data are of interest in any case.

Let us once more extend the example above:

If each customer has multiple addresses, it may be necessary to include a child node for the addresses below the Customer 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 car rental company. To limit the content of a context node at runtime, the context node Address can be assigned the Singleton property. As a result, the elements of the relevant node are instantiated for only one element of the parent node, in this case, the Customer node.

Supply Functions

In order to resynchronize singleton child nodes, the Web Dynpro developer must write a supply function. This method will be associated with the singleton child node, and its purpose is to rebuild the node collection every time the lead selection in the parent element changes. The Web Dynpro framework will then automatically call your supply function when both of the following two conditions are satisfied:

  • The lead selection in the parent node has changed.

  • An attempt is made to read the contents of the singleton child node.