Wednesday, March 7

Dialog Boxes in Web Dynpro ABAP



Dialog boxes display possible settings or concrete information on a Web Dynpro
view. After the dialog is opened, either the view underneath becomes active again or
user can navigate to another screen. There are two types of dialog boxes:
Modal
This one opens in the current browser window.
Each modal dialog box has its own phase model instance
External
An external dialog box opens in a separate window and can be moved
around the screen independently of the original window.

Calling a Dialog Box
Dialog boxes are implemented within a Web Dynpro application via an additional window and
are generally called by the event handler of an action (Other methods of the phase model can also be used). The component controller contains the interface
IF_WD_WINDOW_MANAGER, with which a new window for the content of the dialog box
can be created and opened. In most cases, a modal dialog box is used in your application.

Calling Dialog Boxes of the Same Component
If the dialog box belongs to the current component by content, you should also create the corresponding window in this component. The method CREATE_WINDOW of the interface IF_WD_WINDOW_MANAGER allows you to create a dialog box in an event handler method from a displayed window at runtime.

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.

Buttons of the Dialog Box
Parameter BUTTON_KIND determines which buttons should appear in the dialog
box. In above example, the constant CO_BUTTONS_YESNOCANCEL is set. This
constant is of WDR_POPUP_BUTTON_KIND type. The values of its domain represent all the meaningful combination possibilities for dialog box buttons, such as OK/Cancel, Yes/No/Cancel, OK etc.

Window of the Dialog Box
In WDDOINIT of the view, the button constants are linked
to appropriate actions. Interface IF_WD_WINDOW contains the method
SUBSCRIBE_TO_BUTTON_EVENT. The actions should be created in dialog box
and then event handlers 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.

WDDOONOPEN and WDDOONCLOSE Methods
Window controller has the hook methods WDDOONOPEN and WDDOONCLOSE.
These methods are processed when a window is opened, or closed as a dialog box.The method WDDOONOPEN can be used to implement initializations.

No comments:

Post a Comment

You are welcome to express your views here...