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 ...
随机推荐
- java 导入Excel数据校验判断哪行那列
记录工作 需求是导入数据的时候需要判断哪一行是空行,或者哪一行超过限制字符,然后返回给前端做展示 @PostMapping("/importExcel") @ApiOperatio ...
- VM部署服务后设置局域网内其他人访问
第一种方式:虚拟机设置中,网络适配器选择桥接模式,此时虚拟机IP号段与局域网处于同一号段,局域网内其他人使用虚拟机IP+端口即可访问服务 将虚拟机IP设为静态IP,我的虚拟机系统为Ubuntu20.0 ...
- linux系统下命令行方式创建KVM虚拟机
一:安装虚拟机 1:设备重启进入BIOS打开SMMU,F10保存退出. 2:进入系统安装相关组件 virt-install qemu-kvm qemu-img virt-manager libvi ...
- centos 换源
原文: https://blog.csdn.net/MateSnake/article/details/124088310 备份原来的源:sudo mv /etc/yum.repos.d/CentOS ...
- K8S部署之kubeadm
K8S部署笔记 一.集群环境说明 主机名 IP地址 说明 k8s-master01 192.168.1.107 master节点 k8s-master02 192.168.1.108 master节点 ...
- C#连Mysql数据库报错 SSL Connection error
MySql.Data.MySqlClient.MySqlException (0x80004005): SSL Connection error. ---> System.AggregateEx ...
- ubuntu配置docker全局系统代理
(1)添加用户到docker用户组 sudo groupadd docker sudo gpasswd -a kang docker (注销系统当前用户,再次登录) #检查是否添加到组 cat /et ...
- Nginx结合tomcat 负载均衡
负载均衡是我们大流量网站要做的一个东西,下面我来给大家介绍在Nginx服务器上进行负载均衡配置方法,希望对有需要的同学有所帮助哦. 负载均衡 先来简单了解一下什么是负载均衡,单从字面上的意思来理解就可 ...
- VUE3 API之watch与watchEffect
watch(source,callback,options) 官方术语:侦听一个或多个响应式数据源,并在数据源变化时调用所给的回调函数. watchEffect(effect,options) 官方术 ...
- laravel phpstorm ide-helper
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ composer create-proj ...