
An interface view of a dynamically embedded component must be included dynamically into the navigation of a window. You can implement this, for example, in a method of the controller of the view that launches the navigation. The code fragment below shows the instantiation of the dynamically embedded component.
data: L_VIEW_CONTROLLER_API type ref to IF_WD_VIEW_CONTROLLER, L_COMPONENT_USAGE type ref to IF_WD_COMPONENT_USAGE, COMPONENT_NAME type STRING. if L_COMPONENT_USAGE->HAS_ACTIVE_COMPONENT( ) is initial. L_COMPONENT_USAGE->CREATE_COMPONENT( COMPONENT_NAME ). endif.
Then the method PREPARE_DYNAMIC_NAVIGATION of the runtime API of the view controller is called. All attributes of the own - that is, the using - component are known and can be implemented statically (source attributes). All attributes of the used component are unknown at design time and are passed as variables (target attributes, values are displayed as placeholders in pointed brackets).
L_VIEW_CONTROLLER_API = WD_THIS->WD_GET_API( ). L_VIEW_CONTROLLER_API->PREPARE_DYNAMIC_NAVIGATION( source_window_name = 'W0' source_vusage_name = 'MAIN_USAGE_1' source_plug_name = 'TO_V1' target_component_name = <component_name> target_component_usage = <component_usage_name> target_view_name = <interface_view_name> target_plug_name = <inbound_plug_name> target_embedding_position = <embedding_position> ).
The method PREPARE_DYNAMIC_NAVIGATION of the API of the view controller embeds the interface view <interface_view_name> of component <component_name> at the respective embedding position <embedding_position> (see below). In addition, a navigation link is created from the outbound plug TO_V1 of the view MAIN to the inbound plug <inbound_plug_name> of the interface view <interface_view_name>. The component specified in <component_name> must implement the component interface to which the component usage <component_usage_name> points.
In the last step of this fragment, the outbound plug is called.
WD_THIS->FIRE_TO_V1_PLG( ). . .
Embedding Position of the Interface View
When embedding the interface view, different cases may be of relevance:
This view container element can exist in the embedding view if it has been declared statically. In this case, the embedded interface view will also be displayed automatically and together with the embedding view after specifying the view container element as the value for the embedding position in method PREPARE_DYNAMIC_NAVIGATION.
data: L_ROOT_CNT type ref to CL_WD_UIELEMENT_CONTAINER, L_VIEW_CNT type ref to CL_WD_VIEW_CONTAINER_UIELEMENT, L_MATRIX_HEAD_DATA type ref to CL_WD_MATRIX_HEAD_DATA. if first time = abap_true. L_ROOT_CNT ?= VIEW->GET_ELEMENT( 'ROOTUIELEMENTCONTAINER' ). L_VIEW_CNT = CL_WD_VIEW_CONTAINER_UIELEMENT=>NEW_VIEW_CONTAINER_UIELEMENT( ID = 'CNT1' ). L_ROOT_CNT->ADD_CHILD( L_VIEW_CNT ). L_MATRIX_HEAD_DATA = CL_WD_MATRIX_HEAD_DATA=>NEW_MATRIX_HEAD_DATA( ELEMENT = L_VIEW_CNT ). endif.