Vous êtes sur la page 1sur 4

CONTEXT : Context is used to store UI related data. Context is available at every controller of a component.

An attribute is a context entity that has certain properties and can be directly created in the root node CONTEXT, or as a child for another node. Usually, a node is used to group more attributes that belong together. A context node can have attributes or can hold other nodes, but a context attribute cannot have other attributes or nodes. The root node CONTEXT is automatically created when the controller is initialized and all the nodes and attributes we created are children of this root node.

GETTER & SETTER METHODS : Node is used to stored single or multiple data of UI elements. Node is always associated with interface IF_WD_CONTEXT_NODE Attributes of a node is associated with interface IF_WD_CONTEXT_ELEMENT. Steps to read or set any single or multiple attribute value related to context node: 1. Through the reference of root context node (i.e. WD_CONTEXT ) call the instance method GET_CHILD_NODE to get corresponding child node reference (IF_WD_CONTEXT_NODE ). Pass the required node name to this method which in turns returns the required node reference. DATA : LR_NODE TYPE REF TO IF_WD_CONTEXT_NODE. LR_NODE = WD_CONTEXT->GET_CHILD_NODE ( WDTCX_<NODE NAME> ).

2. Get the element reference (IF_WD_CONTEXT_ELEMENT) through the child node reference by using instance method GET_ELEMENT. DATA : LR_ELE TYPE REF TO IF_WD_CONTEXT_ELEMENT. LR_ELE = LR_NODE->GET_ELEMENT ( ). 3. Using this element reference we can read or set any single or multiple attribute values of context node. a. To read any single attribute of context node use the method GET_ATTRIBUTE DATA : <LV_VALUE> TYPE WD_THIS->ELEMENT_<NODE NAME>-ATTR NAME. LR_ELE->GET_ATTRIBUTE( EXPORTING NAME = ATTRIBUTE NAME IMPORTING VALUE = <LV_VALUE> ). b. To read multiple attributes of a context node use the method GET_STATIC_ATTRIBUTES DATA <LS_VALUE> TYPE REF TO WD_THIS->ELEMENT_<NODE NAME>. LR_ELE->GET_STATIC_ATTRIBUTES ( IMPORTING STATIC_ATTRIBUTES = <LS_VALUE> ). c. To set any value to single attribute of context node use the method SET_ATTRIBUTE DATA : <LV_VALUE> TYPE WD_THIS->ELEMENT_<NODE NAME>-ATTR NAME. LR_ELE->SET_ATTRIBUTE( EXPORTING NAME = ATTRIBUTE NAME VALUE = <LV_VALUE> ). d. To set multiple attributes of a context node use the method SET_STATIC_ATTRIBUTES DATA <LS_VALUE> TYPE REF TO WD_THIS->ELEMENT_<NODE NAME>. LR_ELE->SET_STATIC_ATTRIBUTES ( EXPORTING STATIC_ATTRIBUTES = <LS_VALUE> ).

Vous aimerez peut-être aussi