Entering content frame

Background documentation Dynamic Context Manipulation Locate the document in its SAP Library structure

You can manipulate the context of a controller in different ways at runtime.

Note To support the dynamic programming of contexts and view layouts, the Web Dynpro framework offers a number of methods in the service class CL_WD_DYNAMIC_TOOL. This class contains the frequently used methods in a predefined form. However, you can also implement yourself all the methods for dynamic context manipulation implemented in this class within the Web Dynpro framework. However, note that not all technically possible options are available in this class. In many cases, you will carry out your programming via the relevant framework interfaces to be able to use advanced functions.

 

Example To get an overview of how this class is used, have a look at the example component DEMODYNAMIC in the SWDP_DEMO package, which was delivered together with your system.

 

Adding Context Nodes

Adding a node to a context at runtime may be necessary for a variety of reasons. In highly generically programmed components, the number of required nodes may not be known at design time. Even if the number is known, the structure of the node may become known only at runtime. In such a case, the node is also created and typed dynamically.

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

Alternatively, the service class CL_WD_DYNAMIC_TOOL contains the method

CREATE_NODEINFO_FROM_STRUCT, but with limited functionality.

 

Note If you delete the node info, then all instances of the related node are automatically deleted as well.

Note In contrast to statically created context nodes, the length of the name of a dynamically created node is not limited.

 
The Attribute Structure of the Node

The method CREATE_NODEINFO_FROM_STRUCT expects a known structure to be passed, which means that the node created in such a way automatically has a fixed set of attributes in accordance with the selected structure. However, you can always add individual attributes to this structure (see below). Basically, you could also dynamically create an empty node and fill it with attributes afterwards. However, the service class CL_WD_DYNAMIC_TOOL does not provide a prepared method for this.

Binding a UI Element to a Dynamically Created Context Node

The dynamic bind of a UI element to a context node is programmed at the UI element (see chapter Dynamic Layout Manipulation).

 

Adding Context Attributes

It can make sense to add or remove parameters to or from a context node, depending on the parameters evaluated at runtime. If you created a context node with a DDIC structure at design time, you can create additional attributes only dynamically. In generic applications it may happen that the type of an attribute is not yet known at design time; in this case, you will also create and type this attribute dynamically.

For this purpose, the interface IF_WD_CONTEXT_NODE_INFO contains the method ADD_ATTRIBUTE.  

Fixed Values of Attributes

A UI element can be bound to a dynamically created context node. The UI element may access fixed values of context attributes. In this case, it is necessary to determine fixed values for the attributes. For more information, see Fixed Values of Attributes.

 

 

Leaving content frame