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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

偶是不器

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值