Web Dynpro for ABAP(11):Dialog Boxes
3.16 Working with Dialog Boxes
使用弹出框。
通过接口: IF_WD_WINDOW_MANAGER
方法:CREATE_POPUP_TO_CONFIRM,创建弹出框。
注:其中设置窗口大小位置的方法不生效;
IF_WD_WINDOW~SET_WINDOW_POSITION
IF_WD_WINDOW~SET_WINDOW_POSITION_CONTROL
IF_WD_WINDOW~SET_WINDOW_SIZE
方法:CREATE_POPUP_TO_CONFIRM中参数不生效;
WINDOW_LEFT_POSITION
WINDOW_TOP_POSITION
WINDOW_POSITION
WINDOW_WIDTH
WINDOW_HEIGHT
弹窗在以下UI Elements不生效:
AcfExecute
AcfUpDownload
FlashIsland
All GAC* controls
Gantt
Network
OfficeControl
InteractiveForm
示例:
Component:DEMO_POPUPS_01
Component:DEMO_POPUPS_02
Component: DEMO_POPUPS_03
使用方法CREATE_WINDOW,创建popup显示自定义window内容;
创建Component;
默认Window:V_MAIN;
默认View:MAIN;
创建Window: POPUP1_1,popup显示window;
创建Attributes,M_POPUP1_1,类型:IF_WD_WINDOW;
实现方法,POPUP显示逻辑
示例:
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.
Window:POPUP1_1,实现wddoinit方法,绑定按钮响应action
示例:
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.
使用方法CREATE_WINDOW_FOR_CMP_USAGE, 使用其他Component的Window作为Popup。
参数interface_view_name,表示Window名;
参数component_usage_name,表示使用的component;
示例:
method ONACTIONPOPUP2_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_popup2_1 is initial. wd_this->m_popup2_1 = l_window_manager->CREATE_WINDOW_FOR_CMP_USAGE( interface_view_name = 'MAIN' component_usage_name = 'USAGE_POPUP2_1' ). endif. wd_this->m_popup2_1->open( ). endmethod.
使用方法CREATE_POPUP_TO_CONFIRM,生成确认信息弹出框;
示例:
method onactionpopup4_1 . data: l_cmp_api type ref to if_wd_component, l_window_manager type ref to if_wd_window_manager, l_popup type ref to if_wd_window, l_text type string_table, l_api type ref to if_wd_view_controller. l_cmp_api = wd_comp_controller->wd_get_api( ). l_window_manager = l_cmp_api->get_window_manager( ). insert `Data where changed` into table l_text. "#EC * insert `Do you want to save?` into table l_text. "#EC * l_popup = l_window_manager->create_popup_to_confirm( text = l_text button_kind = if_wd_window=>co_buttons_yesnocancel message_type = if_wd_window=>co_msg_type_question window_title = 'Test: Popup to confirm' window_position = if_wd_window=>co_center )."#EC * l_api = wd_this->wd_get_api( ). l_popup->subscribe_to_button_event( button = if_wd_window=>co_button_yes 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 action_name = 'NO' action_view = l_api is_default_button = abap_false ). l_popup->subscribe_to_button_event( button = if_wd_window=>co_button_cancel action_name = 'CANCEL' action_view = l_api is_default_button = abap_false ). l_popup->open( ). endmethod.
本文来自博客园,作者:渔歌晚唱,转载请注明原文链接:https://www.cnblogs.com/tangToms/p/16365479.html