A number of predefined methods are provided by the controller. These methods, which are called by the Web Dynpro runtime in a predefined order, are calledhook methods.
As these methods are empty at the time of controller creation, the developer can write any desired code in it.
The developer can also define additional methods, such as ordinary methods, event-handler methods, or supply functions.
STANDARD HOOK METHODS FOR ALL CONTROLLERS
This slide depicts the two standard hook methods that exist for all controller types:
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
STANDARD HOOK METHODS: COMPONENT
Additional hook methods are available, depending on the controller type.
WDDOBEFORENAVIGATION( ) is called after the action method is processed and just before the events in the navigation queue are processed by the Web Dynpro framework.
WDDOPOSTPROCESSING( ) is the last controller method that is processed before the UI is sent to the client.
WDDOAPPLICATIONSTATECHANGE( ) is processed each time the application is suspended or resumed. You can suspend a Web Dynpro application by firing a suspend plug of the window. The suspended Web Dynpro application can be resumed by a resume plug.
STANDARD HOOK METHODS: VIEW CONTROLLER
View controllers have access to four additional hook methods:
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
PHASE MODEL (SIMPLE CASE)
Controller methods are processed in a certain order, which is described in the phase model:
When starting a Web Dynpro application (Application start),
the method WDDOINIT( ) instantiates all controllers needed for the first display;
the inbound plug method HANDLEDEFAULT( ) processes the interface view related to the application; and
the component controller methods WDDOBEFORENAVIGATION( ) and WDDOPOSTPROCESSING( ), and the view controller method WDDOMODIFYVIEW( ), are all processed accordingly.The phase model for a request triggered by a user interaction describes the action handler method, inbound plug handler method, and component and view controller methods (Navigation to view):
WDDOBEFOREACTION( ), ONACTION<ACTION>( ) and WDDOAFTERACTION( ) are processed if the client side event is bound to an action.
The component controller method WDDOBEFORENAVIGATION( ) is processed.
The inbound plug method Handle<PLUG>( ) is processed if
an outbound plug is fired;
a navigation link to an inbound plug is defined; and
the view related to the inbound plug is instantiated by processing the method WDDOINIT( ).The method WDDOEXIT( ) is processed if the life time of the previous view is restricted.
The view controller method WDDOMODIFYVIEW( ) is processed for the next View.
Finally, the component controller method WDDOPOSTPROCESSING( ) is processed.
When starting a Web Dynpro application (Application start),
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
WDDOBEFOREACTION( ), ONACTION<ACTION>( ) and WDDOAFTERACTION( ) are processed if the client side event is bound to an action.
The component controller method WDDOBEFORENAVIGATION( ) is processed.
The inbound plug method Handle<PLUG>( ) is processed if
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
The view controller method WDDOMODIFYVIEW( ) is processed for the next View.
Finally, the component controller method WDDOPOSTPROCESSING( ) is processed.
ADDITIONAL CONTROLLER METHODS
You can create additional methods by
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
These methods are automatically called from the Web Dynpro framework if the node is accessed and it is marked as invalid.
You can set the Interface flag for a user-defined component controller method so that the method is also visible to other components.
STANDARD CONTROLLER ATTRIBUTES
Each controller has at least two predefined attributes.
The standard attributes are
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
USER-DEFINED CONTROLLER ATTRIBUTES AND CONTROLLER METHODS
You can define additional attributes for the related controller on the Attributes tab.
These attributes are also visible for other controllers of the same Web Dynpro component if the Public flag is set.
Attributes cannot be exposed to the component’s interface.
ACCESSING A CONTEXT NODE
A local interface is generated with the name IF_<ctrl> for each controller.
A constant (WDCTX_<node>) is generated in this interface for each node <node> of a controller context.
A standard attribute WD_CONTEXT is used to access the context root node.
The get_child_node( ) method is used to identify the child nodes of the context root nodes.
ACCESSING THE NODE ELEMENT AT LEAD SELECTION
You can use the method get_element( ) for reference to the element at lead selection of the context node being accessed. This method returns a reference to the element instance of type IF_WD_CONTEXT_ELEMENT.
ACCESSING CONTEXT NODES AND NODE ELEMENTS
To identify the child nodes of the context root nodes, use the method get_child_node( ).
To access the element with index n, use the method get_element(index= n).
To obtain the number of elements in a collection, use the method get_element_count( ).
ACCESSING A SINGLE ATTRIBUTE OF A NODE ELEMENT
You can use the method get_attribute( ) to access any attribute of a node element.
The name of the attribute must be exported and the import parameter returns the attribute value.
ACCESSING ALL STATICALLY DEFINED ATTRIBUTES OF A NODE ELEMENT
You can use the method get_static_attributes( ) to obtain statically defined attributes. A structure is returned in an import parameter.
ACCESS TO THE STATIC ATTRIBUTES OF ALL NODE ELEMENTS
You can use the method get_static_attributes_table( ) to retrieve the attributes of all elements as an internal table.
CHANGING A SINGLE ATTRIBUTE OF A NODE ELEMENT
You can use the method set_attribute( ) to change the value of any attribute of the node element.
CHANGING MULTIPLE ATTRIBUTES OF A NODE ELEMENT
The method set_static_attributes( ) can be used to change multiple attributes that are statically defined.
ACCESSING AND CHANGING ATTRIBUTES: CONTROLLER NODE
You can use the method get_attribute( ) to access any attribute of a node element. The name of the attribute must be exported and the import parameter returns the attribute value.
You can use the method get_static_attributes( ) to obtain statically defined attributes. A structure is returned in an import parameter.
You can use the method get_static_attributes_table( ) to retrieve the attributes of all elements as an internal table.
You can use the method set_attribute( ) to change the value of any attribute of the node element.
The method set_static_attributes( ) can be used to change multiple attributes that are statically defined.
GETTING THE REFERENCE TO A CONTEXT NODE
You can create an element that can be added to a certain context node. The reference to this node is determined by using the get_child_node( ) method of the standard attribute WD_CONTEXT, which points to the context root node.
CREATING A NEW NODE ELEMENT
You can use the method create_element( ) to create the new element, once you obtain the reference to the node.
SETTING THE ATTRIBUTE VALUES OF THE NEW ELEMENT
The attribute values can be defined using the setter methods set_attribute( ) or set_static_attributes( ).Initial values for the static attributes can be set using thestatic_attribute_values parameter.
BINDING AN ELMENT TO A CONTEXT NODE
The method bind_element( ), related to the node reference, helps you to finally add an element (not yet part of the context node) to the node.
This method has two import parameters:
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
/TAW12_Col92_en_TAW12_ABAP_Objects_and_Application_Areas/shell/assets/bullet.gif)
BINDING A STRUCTURE TO A CONTEXT NODE
You can use method bind_structure( ) with parameter new_item to bind a structure. The existing collection can be extended or replaced by using the parameterset_initial_elements.
BINDING AN INTERNAL TABLE TO A CONTEXT NODE
You can use the method bind_table( ) with parameter new_item to bind an internal table. You can use the parameter set_initial_elements to extend or replace the existing collection.
ADDING/DELETING ELEMENTS: CONTEXT NODE
You can use the method create_element( ) to create the new element once the reference to the node is obtained.
You can use the method bind_element( ) related to the node reference to add an element to the node.
You can use method bind_structure( ) with the parameter new_item to bind a structure. The existing collection can be extended or replaced by using the parameter set_initial_elements.
You can use method bind_table( ) with the parameter new_item to bind an internal table. The existing collection can be extended or replaced by using the parameter set_initial_elements.
You can use the method remove_element() to remove an element from the collection.
No comments:
Post a Comment