1.14 WDA Popup,Message,Focus

WDA测试Popup,Message,光标Focus功能。

1.创建Component;

COMPONENTCONTROLLER页签

Context页签:创建Context Node:MESSAGE;

创建Attribute:MSG,类型CHAR1;

创建Attribute:MSG_TYPE,类型String;

Attributes页签:创建Attribute,名称POPUP,类型IF_WD_WINDOW;

Methods页签:创建Method,名称SHOW_MSG;

设置Parameter,名称MSG,类型STRING;

设置Parameter,名称MSG_TYPE,类型CHAR1;

代码实例:

  "显示信息
DATA: lo_current_controller TYPE REF TO if_wd_controller,
lo_message_manager TYPE REF TO if_wd_message_manager. "获取message manager
lo_current_controller ?= wd_this->wd_get_api( ).
CALL METHOD lo_current_controller->get_message_manager
RECEIVING
message_manager = lo_message_manager. "report message
IF msg_type = 'S'.
CALL METHOD lo_message_manager->report_success
EXPORTING
message_text = msg.
ELSEIF msg_type = 'E'.
CALL METHOD lo_message_manager->report_error_message
EXPORTING
message_text = msg.
ELSEIF msg_type = 'I'.
CALL METHOD lo_message_manager->report_message
EXPORTING
message_text = msg.
ENDIF. 

2.创建Main View,设置Layout;

1.Pop弹窗功能:使用Popup打开Window

使用if_wd_window_manager的create_window创建窗口,window_name这个参数设置自定义的Window;

这种方式需要创建VIEW:V_POP1,Layout只显示一个Message,也可以自定义页面;

然后创建Window Name:W_POP,包含VIEW:V_POP1;

创建LinkToAction组件,名称pop to window,绑定Action:POP_TO_WINDOW;

代码实例:

  data:lo_window_manager type ref to if_wd_window_manager.
data:lo_api_component type ref to if_wd_component.
data:lo_api type ref to if_wd_view_controller. if wd_comp_controller->popup is initial.
* create window
lo_api_component = wd_comp_controller->wd_get_api( ).
lo_window_manager = lo_api_component->get_window_manager( ).
wd_comp_controller->popup = lo_window_manager->create_window(
window_name = 'W_POP'
title = '弹窗1'
message_display_mode = if_wd_window=>CO_MSG_DISPLAY_MODE_NONE
close_button = abap_true
button_kind = if_wd_window=>CO_BUTTONS_YESNO "use constants if_wd_window=>CO_BUTTONS_*
message_type = if_wd_window=>CO_MSG_TYPE_QUESTION "use constants if_wd_window=>CO_MSG_TYPE_*
default_button = if_wd_window=>CO_BUTTON_YES "use constants if_wd_window=>CO_BUTTON_*
close_in_any_case = abap_false
). lo_api = wd_this->wd_get_api( ).
* subscribe to YES-Button
wd_comp_controller->popup->subscribe_to_button_event(
button = if_wd_window=>co_button_yes
action_name = 'YES'
action_view = lo_api
).
* subscribe to NO-Button
wd_comp_controller->popup->subscribe_to_button_event(
button = if_wd_window=>co_button_no
action_name = 'NO'
action_view = lo_api
). ENDIF.
* open popup
wd_comp_controller->popup->open( ).

POP_TO_WINDOW这里注册了YES,NO两个Action,需要在Main View创建Action:YES,NO。设置MSG点击了yes or no;

实例代码ONACTIONYES:

    DATA lo_nd_message TYPE REF TO if_wd_context_node.
DATA lo_el_message TYPE REF TO if_wd_context_element.
DATA ls_message TYPE wd_this->Element_message.
DATA lv_msg TYPE wd_this->Element_message-msg. * navigate from <CONTEXT> to <MESSAGE> via lead selection
lo_nd_message = wd_context->get_child_node( name = wd_this->wdctx_message ).
* get element via lead selection
lo_el_message = lo_nd_message->get_element( ). lv_msg = '点击yes'.
* set single attribute
lo_el_message->set_attribute(
name = 'MSG'
value = lv_msg ).
"关闭弹窗
wd_comp_controller->popup->close( ).

2.Message Manager显示信息功能

创建Button组件,绑定Action: SHOW_MSG;

创建DropDownByKey组件,选择message类型;

代码实例:获取Message类型,调用component controller的show_msg方法;

  DATA:lo_nd_message TYPE REF TO if_wd_context_node.
DATA:lo_el_message TYPE REF TO if_wd_context_element.
DATA:lv_msg_type TYPE wd_this->element_message-msg_type.
DATA:lv_msg TYPE string VALUE '显示信息'.
"获取信息类型
lo_nd_message = wd_context->get_child_node( name = 'MESSAGE' ).
lo_el_message = lo_nd_message->get_element( ).
lo_el_message->get_attribute(
EXPORTING
name = 'MSG_TYPE'
IMPORTING
value = lv_msg_type
).
* report message
IF lv_msg_type = 'S'.
wd_comp_controller->show_msg( msg = lv_msg msg_type = 'S' ).
ELSEIF lv_msg_type = 'E'.
wd_comp_controller->show_msg( msg = lv_msg msg_type = 'E' ).
ELSEIF lv_msg_type = 'I'.
wd_comp_controller->show_msg( msg = lv_msg msg_type = 'I' ).
ELSEIF lv_msg_type = 'W'.
wd_comp_controller->show_msg( msg = lv_msg msg_type = 'W' ).
ENDIF. 

创建INIT_DROPDOWN方法;

初始化方法WDDOINIT中调用INIT_DROPDOWN方法;

  "设置dropdown 信息类型
DATA:wd_node_info TYPE REF TO if_wd_context_node_info.
DATA:wd_node TYPE REF TO if_wd_context_node.
DATA value_set TYPE wdr_context_attr_value_list.
DATA entry TYPE wdr_context_attr_value.
wd_node = wd_context->get_child_node( name = 'MESSAGE' ).
*初始化
entry-text = 'S'.
entry-value = 'S'.
APPEND entry TO value_set.
entry-text = 'E'.
entry-value = 'E'.
APPEND entry TO value_set.
entry-text = 'W'.
entry-value = 'W'.
APPEND entry TO value_set.
wd_node_info = wd_node->get_node_info( ).
wd_node_info->set_attribute_value_set( name = 'MSG_TYPE' value_set = value_set ).

3.External Window功能

通过URL打开其他WDA Application;

创建LinkToAction组件,open url,绑定Action: OPEN_URL;

创建LinkToAction组件,Open Application Url,绑定Action:OPEN_APPL_URL;

代码实例:ONACTIONOPEN_URL

通过if_wd_window_managet->create_external_window方法,打开新页签URL;

  DATA:lo_window_manager TYPE REF TO if_wd_window_manager.
DATA:lo_api_component TYPE REF TO if_wd_component.
DATA:lo_view_control TYPE REF TO if_wd_view_controller.
DATA:lo_window TYPE REF TO if_wd_window. "获取view controller
lo_view_control = wd_this->wd_get_api( ).
"获取view component
lo_api_component = lo_view_control->if_wd_controller~get_component( ). "获取window manager
lo_window_manager = lo_api_component->get_window_manager( ).
lo_window_manager->create_external_window(
EXPORTING
url = 'https://www.baidu.com'
title = 'open external window'
modal = abap_false
has_menubar = abap_true "false,弹出新窗口打开网页;
is_resizable = abap_false "是否可重设大小
has_scrollbars = abap_false
has_statusbar = abap_false
has_toolbar = abap_false "false,没有标签,收藏等工具栏
has_location = abap_true "false,没有上一页,下一页,搜寻工具栏
RECEIVING
window = lo_window
).
"打开window
lo_window->open( ).

代码实例:ONACTIONOPEN_APPL_URL

通过cl_wd_utilities=>construct_wd_url,根据component获取对应url;

  DATA:lo_window_manager TYPE REF TO if_wd_window_manager.
DATA:lo_api_component TYPE REF TO if_wd_component.
DATA:lo_window TYPE REF TO if_wd_window.
DATA:lv_url TYPE string.
"获取application url
cl_wd_utilities=>construct_wd_url(
EXPORTING
application_name = 'Z_TEST_WDA96'
IMPORTING
out_absolute_url = lv_url
).
* "添加parameter
* cl_http_server=>if_http_server~append_field_url(
* EXPORTING
* name = 'param1'
* value = 'value1'
* CHANGING
* url = lv_url
* ). "获取 component controller
lo_api_component = wd_comp_controller->wd_get_api( ).
"获取window manager
lo_window_manager = lo_api_component->get_window_manager( ).
lo_window_manager->create_external_window(
EXPORTING
url = lv_url
title = 'open external window'
modal = abap_false
has_menubar = abap_true "false,弹出新窗口打开网页;
is_resizable = abap_false "是否可重设大小
has_scrollbars = abap_false
has_statusbar = abap_false
has_toolbar = abap_false "false,没有标签,收藏等工具栏
has_location = abap_true "false,没有上一页,下一页,搜寻工具栏
RECEIVING
window = lo_window
).
"打开window
lo_window->open( ). 

4.Pop弹出功能:使用Popup创建弹窗

点击按钮打开弹窗;

创建LinkToAction组件,绑定Action:POP_TO_CONFIRM;

代码实例:ONACTIONPOP_TO_CONFIRM

使用if_wd_window_manager->create_popup_to_confirm方法创建一个confirm弹窗;

  DATA:lo_window_manager TYPE REF TO if_wd_window_manager.
DATA:lo_api_component TYPE REF TO if_wd_component.
DATA:lo_view_controller TYPE REF TO if_wd_view_controller.
DATA:lo_window TYPE REF TO if_wd_window.
DATA:lv_string TYPE string.
DATA:lt_string TYPE TABLE OF string. "获取当前视图controller
lo_view_controller = wd_this->wd_get_api( ).
lo_api_component = lo_view_controller->if_wd_controller~get_component( ).
lo_window_manager = lo_api_component->get_window_manager( ).
lv_string = 'This is Pop up to Confirm'.
APPEND lv_string TO lt_string.
lv_string = 'This is Pop up to Confirm'.
APPEND lv_string TO lt_string. lo_window_manager->create_popup_to_confirm(
EXPORTING
text = lt_string
button_kind = if_wd_window=>co_buttons_yesno
message_type = if_wd_window=>co_msg_type_information
close_button = abap_true "关闭按钮
window_title = 'Pop up confirm'
window_left_position = 100
window_top_position = 200
window_position = if_wd_window=>co_center
window_width = '200px'
window_height = '400px'
default_button = if_wd_window=>co_button_yes
RECEIVING
result = lo_window
). lo_window->subscribe_to_button_event(
EXPORTING
tooltip = 'yes'
button_text = 'button yes'
button = if_wd_window=>co_button_yes
action_name = 'HDL_YES'
action_view = lo_view_controller
).
lo_window->subscribe_to_button_event(
EXPORTING
tooltip = 'no'
button_text = 'button no'
button = if_wd_window=>co_button_no
action_name = 'HDL_NO'
action_view = lo_view_controller
).
"设置任何action发生后关闭
lo_window->set_close_in_any_case( abap_true ).
"打开pop
lo_window->open( ).
"直接调用关闭
"lo_window->close( ). 

代码实例:ONACTIONHDL_YES,处理YES点击事件;

wd_comp_controller->show_msg( msg = 'yes' msg_type = 'S' ).

代码实例:ONACTIONHDL_NO,处理NO点击事件;

wd_comp_controller->show_msg( msg = 'no' msg_type = 'S' ). 

5.UI Element Focus功能

设置UI Element鼠标Focus;

MAIN View的初始化方法WDDOINIT方法调用INIT_INPFOCUS方法;

创建INIT_INPFOCUS方法;

代码实例:

通过if_wd_view_controller->request_focus方法,设置focus;

  DATA:lo_node TYPE REF TO if_wd_context_node.
DATA:lo_element TYPE REF TO if_wd_context_element.
DATA:ls_inp TYPE wd_this->element_node_inp.
DATA:lo_view_controll TYPE REF TO if_wd_view_controller. lo_view_controll = wd_this->wd_get_api( ).
lo_node = wd_context->get_child_node( wd_this->wdctx_node_inp ).
lo_element = lo_node->get_element( ).
ls_inp-inp1 = 'hello'.
ls_inp-inp2 = 'world'. "设置值
lo_element->set_static_attributes(
EXPORTING
static_attributes = ls_inp
).
"设置Focus
lo_view_controll->request_focus(
EXPORTING
context_element = lo_element
attribute = 'INP2'
).

WDA学习(21):WDA Popup,Message,Focus的更多相关文章

  1. Asp.NetCore源码学习[2-1]:日志

    Asp.NetCore源码学习[2-1]:日志 在一个系统中,日志是不可或缺的部分.对于.net而言有许多成熟的日志框架,包括Log4Net.NLog.Serilog 等等.你可以在系统中直接使用这些 ...

  2. WDA基础十五:POPUP WINDOW

    1.组件控制器定义属性: 2.实现popup方法: METHOD stock_popup . DATA: l_cmp_api TYPE REF TO if_wd_component, l_window ...

  3. python学习(21) smtp发送邮件

    原文链接: https://www.jianshu.com/p/369ec15bfe22 本文介绍python发送邮件模块smtplib以及相关MIME模块.smtplib用于生成邮件发送的代理,发送 ...

  4. OpenCV学习(21) Grabcut算法详解

    grab cut算法是graph cut算法的改进.在理解grab cut算之前,应该学习一下graph cut算法的概念及实现方式. 我搜集了一些graph cut资料:http://yunpan. ...

  5. JavaSE入门学习21:Java面向对象之接口(interface)(二)

    一接口实现的多态 在上一篇博文:JavaSE入门学习20:Java面向对象之接口(interface)(一)中提到了接口的实现存在多态性,那么 这一篇主要就要分析接口实现的多态. 实例一 Test.j ...

  6. mac虚拟机搭建自动化环境-wda和python wda client

    尽量升级Xcode到最新版,保持iPhone的版本大于9.3 1.安装webDriverAgent到ios真机 从github上下载代码:git clone https://github.com/fa ...

  7. Asp.NetCore源码学习[2-1]:配置[Configuration]

    Asp.NetCore源码学习[2-1]:配置[Configuration] 在Asp. NetCore中,配置系统支持不同的配置源(文件.环境变量等),虽然有多种的配置源,但是最终提供给系统使用的只 ...

  8. Salesforce LWC学习(二十三) Lightning Message Service 浅谈

    本篇参考: https://trailhead.salesforce.com/content/learn/superbadges/superbadge_lwc_specialist https://d ...

  9. Python学习--21天Python基础学习之旅(Day08-Day21)

    Day08: Chapter 11 异常 1.1如果try代码块中代码运行没有问题,则运行时跳过except代码块.(有异常时执行except中的代码,没有异常则跳过except中的代码) try-e ...

  10. Python学习--21天Python基础学习之旅(Day01、Day02)

    21天的python基础学习,使用<Python从入门到实践>,并且需要手敲书中的code,以下为整个学习过程的记录. Day01: 安装python时要选择复选框 Add Python ...

随机推荐

  1. PHP的session文件包含与竞争

    PHP的session文件包含与竞争 lamaper@qq.com lamaper - 博客园 (cnblogs.com) 一.什么是Session Session:在计算机中,尤其是在网络应用中,称 ...

  2. unity3D mirror网络游戏开发笔记

    最近想开发一款多人在线网络游戏,使用unity3d的mirror插件可以提高开发效率,并且该插件免费. 但是由于使用插件开发效率太低,经过研究,ummorpg开发模板是居于该插件开发而来,使用它可以提 ...

  3. Flink Table API & SQL 自定义Redis Sink 使用方式

    flink-connector-redis的使用方式和其他连接器几乎一样,除了一些公共的参数外(connector.type, format.type, or update-mode等),还支持以下参 ...

  4. 在Windows上安装torch遇到的部分问题

    1.版本问题 老师新买的这台机器是RTX 3060,没动显卡驱动,直接安装的CUDA,装的11.4,完全按照这篇blog来的,非常舒服:https://blog.csdn.net/qq_4504187 ...

  5. sxt_(015)_request处理表单数据及乱码

    一.request处理表单数据及乱码 1.1 处理单个表单数据用request.getParameter("x"); 1.2 处理多个表单(checkbox.select)数据用r ...

  6. Django操作redis

    一.环境安装 基本环境: Python环境:Python 3.8.16 Django环境:4.1 redis环境:参考搭建 https://www.cnblogs.com/yclh/p/1474233 ...

  7. 《Makefile中基本字符串替换函数与处理函数的使用参考》

    https://blog.csdn.net/ababab12345/article/details/120723396

  8. Mysql的性能优化方案

    MySQL的性能优化主要分为以下四个方面 设计: 存储引擎.字段类型.范式与逆范式 功能: 索引.缓存.分库分表.数据库连接池 架构上: 读写分离.集群.均衡负载 合理的SQL: 测试.优化查询语句. ...

  9. DAC双通道模板

    #define DAC_C #include "dac.h" float DAC_DispenseA; float DAC_DispenseB; void MyDAC_Init(v ...

  10. redis分布锁

    1.redis分布式锁应用的场景? 1)防止缓存穿透:热点数据过期,大量线程访问mysql 2)  防止秒杀超卖:库存数量同步给redis后,对redis数据进行扣减 3)双写一致性:缓存的数据,被修 ...