Show TOC

Dynamic Context ManipulationLocate this document in the navigation structure

Use

The context of a controller can be manipulated at runtime in different ways.

Note

To support dynamic programming of contexts and view layouts, the Web Dynpro framework provides a range of methods in service class CL_WD_DYNAMIC_TOOL. In this class you can find frequently used methods. All the methods for dynamic context manipulation implemented in this class you can also implement yourself within the Web Dynpro framework. Bear in mind, however, that not all of the technical options in this class will be available. If you want to use additional functions, in many cases you have to do the programming in the relevant framework interface.

Example

You can find more information about using this class in the example component DEMODYNAMIC in package SWDP_DEMO, which is delivered with your system.

Adding Context Nodes

For different reasons it may be necessary to add a node to a context at runtime. In components that have been heavily generically programmed the number of required nodes may not be known yet at design time. Even if the number is already known, the structure of the node may not be known until runtime. In such cases the node is also created and typed dynamically.

For this purpose interface IF_WD_CONTEXT_NODE_INFO contains method ADD_NEW_CHILD_NODE, which has a range of parameters, such as the name of the new node or the assigned supply method.

Alternatively, service class CL_WD_DYNAMIC_TOOL contains method CREATE_NODEINFO_FROM_STRUCT, though it has restricted functions.

Note

If you want to delete the node information, all instances of the related node are automatically deleted too.

Note

The number of characters permitted for names of dynamically created nodes is unrestricted, unlike for names of statically created context nodes.

Attribute Structure of the Node

Method CREATE_NODEINFO_FROM_STRUCT expects a known structure to be transferred, which means that a node created in this way automatically has a defined set of attributes appropriate to this selected structure. You can still add attributes to this structure (see below). You can also opt to dynamically create an empty node and fill it with attributes later. However, there is no prepared method available for this in service class CL_WD_DYNAMIC_TOOL.

Binding a UI Element to a Dynamically Created Context Node

The dynamic binding of a UI element to a context node is programmed in the UI element (see section Dynamic Layout Manipulation).

Adding Context attributes

In some circumstances it may be practical to add attributes to, or remove them from a context node, independently of parameters evaluated at runtime. If you created a context node with a DDIC structure at design time, you can only dynamically create additional attributes. In generic applications the type of an attribute may not be known yet at design time, so you would not dynamically create and type this attribute until runtime.

Interface IF_WD_CONTEXT_NODE_INFO contains method ADD_ATTRIBUTE for this purpose.

Fixed Values of Attributes

A UI element can be bound to a dynamically created context node. In certain circumstances the UI element may be one that accesses fixed values of context attributes. If it is, you have to define fixed values for the attributes. For more information, see Fixed Values of Attributes.

More Information

For more information about interfaces and classes, see the relevant system documentation.