
If the dialog box that you want to display is connected to the current component by content and was created specifically for this purpose, you should also create the corresponding window in this component.
The CREATE_WINDOW method of the IF_WD_WINDOW_MANAGER interface allows you to create a dialog box in an event handler method from a displayed window at runtime. The name of the window to be opened is passed to the CREATE_WINDOW method as a parameter. An attribute of the type IF_WD_WINDOW must be declared for the dialog box in the view controller. In the example below, this is the m_popup1_1 attribute.
The window used as the dialog box (here: POPUP1_1) must already exist in the component.
method onactionpopup1_1 .
data: l_cmp_api type ref to if_wd_component,
l_window_manager type ref to if_wd_window_manager.
l_cmp_api = wd_comp_controller->wd_get_api( ).
l_window_manager = l_cmp_api->get_window_manager( ).
if wd_this->m_popup1_1 is initial.
wd_this->m_popup1_1 = l_window_manager->create_window(
window_name = 'POPUP1_1'
button_kind = if_wd_window=>co_buttons_yesnocancel
message_type = if_wd_window=>co_msg_type_question ).
endif.
wd_this->m_popup1_1->open( ).
endmethod.
Note that the CREATE_WINDOW method only creates the new dialog box; it does not open it. To open the dialog box, you also need the OPEN method.
Buttons in the Dialog Box
You can use the BUTTON_KIND parameter to specify which buttons should appear in the dialog box. In the example above, the constant CO_BUTTONS_YESNOCANCEL is set. This constant is of the ABAP Dictionary type WDR_POPUP_BUTTON_KIND, the domain of which has a set of fixed values. The fixed values represent all the meaningful combination possibilities for dialog box buttons, such as OK , OK/Cancel , and Yes/No/Cancel . The presetting for the constants, which is an attribute of the IF_WD_WINDOW interface, is the value 5. This means that the combination contains the constants CO_BUTTON_YES, CO_BUTTON_NO, and CO_BUTTON_CANCEL; three buttons are generated in the dialog box - one each for Yes , No , and Cancel .
Hide and Shows Buttons
You can also deactivate one or more buttons. You do this using the SET_BUTTON_ENABLED method of the IF_WD_WINDOW interface.
The popup buttons are always active by default.
Dialog Box Window
In the WDDOINIT hook method of the dialog box view, the button constants are linked to appropriate actions. The IF_WD_WINDOW interface provides the SUBSCRIBE_TO_BUTTON_EVENT method for this purpose. The actions must be created directly in the dialog box and the automatically created event handler methods must be programmed accordingly.
method wddoinit .
data:
l_api type ref to if_wd_view_controller,
l_window_ctlr type ref to if_wd_window_controller,
l_popup type ref to if_wd_window.
l_api = wd_this->wd_get_api( ).
l_window_ctlr = l_api->get_embedding_window_ctlr( ).
if l_window_ctlr is bound.
l_popup = l_window_ctlr->get_window( ).
if l_popup is bound.
l_popup->subscribe_to_button_event(
button = if_wd_window=>co_button_yes
button_text = 'Yes' "#EC *
action_name = 'YES'
action_view = l_api
is_default_button = abap_true ).
l_popup->subscribe_to_button_event(
button = if_wd_window=>co_button_no
button_text = 'No' "#EC *
action_name = 'NO'
action_view = l_api
is_default_button = abap_true ).
l_popup->subscribe_to_button_event(
button = if_wd_window=>co_button_cancel
button_text = 'Cancel' "#EC *
action_name = 'CANCEL'
action_view = l_api
is_default_button = abap_true ).
endif.
endif.
endmethod.
The phase model instance of the dialog box is attached to the same component as the instance of the calling window. For this reason, when the dialog box is opened not only are all the hook methods of the view called that are displayed in the dialog box, all the hook methods of the view that are imbedded in the calling window are called as well.
The WDDOONOPEN and WDDOONCLOSE Methods
Every window controller has the WDDOONOPEN and WDDOONCLOSE hook methods. These two methods are only processed when a window is opened or closed as a dialog box. Since the opening of a dialog box does not involve any navigation, no inbound plug is called and therefore no event handler method is processed. The WDDOONOPEN method can therefore be used to implement initializations.