Direct Reference to a Context Node

To enable programming in a method on the context, the context of the method in question must be known. The first step therefore always consists of passing the reference to the context node.

In all other controller methods, the determination of the reference must be programmed explicitly. This takes place on the basis of the context root node of a controller.

Each controller method automatically recognizes the reference to the root node of its associated context. This reference is called WD_CONTEXT (see Reference Variable WD_CONTEXT) and its type is always IF_WD_CONTEXT_NODE. The GET_CHILD_NODE method now enables the generation of a reference to the required subnodes.

Avoidance of Syntax Errors: Constants for Context Nodes

For every node you create in the context of a controller, a constant with the name WDCTX_<node name> is automatically created in the corresponding interface IG_<controller name> and IF_<controller name>. In the program source code for the controller, this constant can then be used instead of a string literal for the node name by using the reference to the local controller interface (WD_THIS attribute) (see WD_THIS Reference Variable and the Local Controller Interface).

Example

wd_context->get_child_node( wd_this->wdctx_node_1 ).
instead of
wd_context->get_child_node( 'NODE_1' ).

The advantage of using constants is that the compiler knows the constant and, therefore, syntax errors are reported if the name of the context node contains typing errors. However, it is also possible to pass a string literal.

Using this kind of direct reference gives you access to a subnode of the context root node. For more information, see Reference Path to Deeper Context Nodes.