WDA学习(21):WDA Popup,Message,Focus
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的更多相关文章
- Asp.NetCore源码学习[2-1]:日志
Asp.NetCore源码学习[2-1]:日志 在一个系统中,日志是不可或缺的部分.对于.net而言有许多成熟的日志框架,包括Log4Net.NLog.Serilog 等等.你可以在系统中直接使用这些 ...
- WDA基础十五:POPUP WINDOW
1.组件控制器定义属性: 2.实现popup方法: METHOD stock_popup . DATA: l_cmp_api TYPE REF TO if_wd_component, l_window ...
- python学习(21) smtp发送邮件
原文链接: https://www.jianshu.com/p/369ec15bfe22 本文介绍python发送邮件模块smtplib以及相关MIME模块.smtplib用于生成邮件发送的代理,发送 ...
- OpenCV学习(21) Grabcut算法详解
grab cut算法是graph cut算法的改进.在理解grab cut算之前,应该学习一下graph cut算法的概念及实现方式. 我搜集了一些graph cut资料:http://yunpan. ...
- JavaSE入门学习21:Java面向对象之接口(interface)(二)
一接口实现的多态 在上一篇博文:JavaSE入门学习20:Java面向对象之接口(interface)(一)中提到了接口的实现存在多态性,那么 这一篇主要就要分析接口实现的多态. 实例一 Test.j ...
- mac虚拟机搭建自动化环境-wda和python wda client
尽量升级Xcode到最新版,保持iPhone的版本大于9.3 1.安装webDriverAgent到ios真机 从github上下载代码:git clone https://github.com/fa ...
- Asp.NetCore源码学习[2-1]:配置[Configuration]
Asp.NetCore源码学习[2-1]:配置[Configuration] 在Asp. NetCore中,配置系统支持不同的配置源(文件.环境变量等),虽然有多种的配置源,但是最终提供给系统使用的只 ...
- Salesforce LWC学习(二十三) Lightning Message Service 浅谈
本篇参考: https://trailhead.salesforce.com/content/learn/superbadges/superbadge_lwc_specialist https://d ...
- Python学习--21天Python基础学习之旅(Day08-Day21)
Day08: Chapter 11 异常 1.1如果try代码块中代码运行没有问题,则运行时跳过except代码块.(有异常时执行except中的代码,没有异常则跳过except中的代码) try-e ...
- Python学习--21天Python基础学习之旅(Day01、Day02)
21天的python基础学习,使用<Python从入门到实践>,并且需要手敲书中的code,以下为整个学习过程的记录. Day01: 安装python时要选择复选框 Add Python ...
随机推荐
- php 关于 json字符串使用json_decode 转数组为空
项目中遇见一个之前没有遇见的问题,就是 转化一个json字符串为数组时 为空,解决办法是使用 htmlspecialchars_decode 处理一下json字符串 然后 再使用 json_decod ...
- spark2.0.1源码编译
一.编译源码步骤演示详解 . 编译spark环境要求 1.必须在linux系统下编译(以centos6.4为例) 2.编译使用的JDK版本必须是1.6以上(以JDK1.8为例) 3.编译需要使用Mav ...
- PHP Array数组
PHP中的数组实际上是一个有序映射.映射是一种把values关联到keys的类型.此类型在很多方面做了优化,因此可以把它当成真正的数组,或列表(向量),散列表(是映射的一种实现),字典,集合,栈,队列 ...
- Windows下安装和使用Masscan
http://zone.secevery.com/article/1098 0x00 前言Masscan号称最快的互联网端口扫描器,本文来探测一下Masscan在Windows下的安装和使用.mass ...
- pdf导出 预览、直接打印、打印加预览
前台: var xueurl = "fileFormatController.do?getXbDetail_print&id=&codes=" + rowsData ...
- nodejs,阿里云手机号一键登录
const Core = require('@alicloud/pop-core'); const accessKeyId = "xxxx" const accessSecret ...
- 利用XtraBackup实现PXC数据库的热备份
PXC 容器中安装XtraBackup apt-get updata 1.在宿主机创建数据库卷,将数据卷映射到某个数据库的节点上 docker volume create backup 2.暂停nod ...
- uniapp引入微信小程序自定义视频组件--记录
官方文档:https://zh.uniapp.dcloud.io/tutorial/miniprogram-subject.html 在 pages.json同级目录下 创建目录和文件: wxcomp ...
- 【转载】synopsys中工具介绍,VCS,DC,PT等
https://blog.csdn.net/fangxiangeng/article/details/80981536
- 免费赠票 | Cloud Ace 受邀参加 GTC2022 全球流量大会,助力中国企业扬帆出海!
Cloud Ace 受邀参加 GTC2022 全球流量大会,助力中国企业扬帆出海! 大会将在 2023 年 2 月 28 日-3 月 1 日举行,地点就在福田会展中心 6 号展馆.大会门票实行收费 ...