ABAP Webdynpro Interface View的用法-阿里云开发者社区

开发者社区> 开发者小助手-bz6> 正文

ABAP Webdynpro Interface View的用法

简介: ABAP Webdynpro Interface View的用法
+关注继续查看

If the component usage is not defined at design time, it is not possible to embed an interface view of this component usage into a ViewUIElementContainer of another view. It is also not possible to define a navigation link connecting any outbound plug of an existing view to an inbound plug of this interface view at design time. In this case methods of the Web Dynpro API have to be applied.


I will use the example in the following two blogs to demonstrate the trick.


(1) Step by Step to create UI elements and context node attribute in the runtime

(2) Step by step to use Component usage clone


after you specify the number of rows you want to generate and click the create button, all UI elements and context node attribute will be generated in the runtime. The UI elements marked in blue come from the interface view of another component, and this view embedding logic is also done dynamically in the runtime.

image.pngimage.pngimage.png

Step3

In method GET_VALUE_BY_INDEX, store the component usage of both static and dynamic one into the attribute GT_USAGE_NAME created in step 2.

DATA(lo_static_com_usage) = wd_this->wd_cpuse_zclone_example( ).

 DATA: lo_generic_usage TYPE REF TO if_wd_component_usage,

       lo_interface_control TYPE REF TO ZIWCI_DYNAMICUSAGE.

 READ TABLE wd_this->gt_cmp_usages ASSIGNING FIELD-SYMBOL() INDEX iv_index.

 CASE iv_index.

   WHEN 1.

     IF lo_static_com_usage->has_active_component( ) IS INITIAL.

        lo_static_com_usage->create_component( ).

     ENDIF.

APPEND 'ZCLONE_EXAMPLE' TO wd_this->gt_usage_name.

     lo_generic_usage = lo_static_com_usage.

   WHEN OTHERS.

     READ TABLE wd_this->gt_cmp_usages ASSIGNING FIELD-SYMBOL() INDEX iv_index.

     IF sy-subrc <> 0.

        DATA(lv_usage_name) = 'DYNAMIC_USAGE' && sy-index.

        data(lo_dyn_usage) = lo_static_com_usage->create_comp_usage_of_same_type( name = lv_usage_name ).

        APPEND lo_dyn_usage TO wd_this->gt_cmp_usages.

 APPEND lv_usage_name TO wd_this->gt_usage_name.

     ENDIF.

     IF lo_dyn_usage->has_active_component( ) IS INITIAL.

        lo_dyn_usage->create_component( ).

     ENDIF.

     lo_generic_usage = lo_dyn_usage.

  ENDCASE.

  lo_interface_control ?= lo_generic_usage->get_interface_controller( ).

  rv_output = lo_interface_control->get_field_value( iv_index ).

endmethod.Step4

In method ONACTIONCREATE, now also create separate view container UIElement instance for each component usage. That view container will be used to embed

the interface view exposed by component ZDYNAMICUSAGE. Then we use API prepare_dynamic_navigation to create a navigation link dynamically, from host view in component ZDYNAMIC to the interface view of component ZDYNAMICUSAGE. The component usage name stored in attribute gt_usage_name in step 3 will be used during API call. Finally fire the outbound plug of MAIN view to make the embedded view displayed in UI.

method ONACTIONCREATE .

CONSTANTS: cv_label TYPE string VALUE 'LABEL',

cv_field TYPE string VALUE 'FIELD',

   cv_container TYPE string VALUE 'EMBEDDED',

cv_bind_text TYPE string VALUE 'DYNAMIC.VALUE'.

DATA: lv_count type i,

lo_container type ref to cl_Wd_uielement_container.

wd_context->get_attribute( EXPORTING name = 'NUMBER' IMPORTING value = lv_count ).

CHECK lv_count > 0.

create_context( lv_count ).

DATA(lo_root) = wd_this->mr_view->get_element( 'DYNAMICUI' ).

lo_container ?= lo_root.

lo_container->remove_all_children( ).

DO lv_count TIMES.

data(lv_field_id) = cv_field && sy-index.

data(lv_label_id) = cv_label && sy-index.

data(lv_bind_path) = cv_bind_text && sy-index.

DATA(lo_text_view) = cl_wd_text_view=>new_text_view( id = lv_field_id bind_text = lv_bind_path ).

DATA(lo_label) = cl_wd_label=>new_label( id = lv_label_id label_for = lo_text_view->id text = lv_label_id ).

CL_WD_ROW_HEAD_DATA=>new_row_head_data( element = lo_label ).

cl_wd_row_data=>new_row_data( element = lo_text_view ).

DATA(lv_container_id) = cv_container && sy-index.

data(lo_view_cont) = CL_WD_VIEW_CONTAINER_UIELEMENT=>new_view_container_uielement( id = lv_container_id ).

   CL_WD_ROW_HEAD_DATA=>new_row_head_data( element = lo_view_cont ).

lo_container->add_child( the_child = lo_label ).

lo_container->add_child( the_child = lo_text_view ).

   lo_container->add_child( the_child = lo_view_cont ).

ENDDO.

DATA: lr_api_main_view TYPE REF TO if_wD_view_controller.

lr_api_main_view = wd_this->wd_get_api( ).

DO lv_count TIMES.

 READ TABLE wd_this->gt_usage_name ASSIGNING FIELD-SYMBOL() INDEX sy-index.

DATA(lv_position) = 'MAIN/' && cv_container && sy-index.

lr_api_main_view->prepare_dynamic_navigation(

      source_window_name = 'ZDYNAMIC'

      source_vusage_name = 'MAIN_USAGE_0'

      source_plug_name   = 'VIEW_TO_USAGE'

      target_component_name = 'ZDYNAMICUSAGE'

      target_component_usage =

      target_view_name       = 'ZDYNAMICUSAGE'

      target_plug_name       = 'DEFAULT'

      target_embedding_position = lv_position ).

   wd_this->fire_view_to_usage_plg( ).

ENDDO.

endmethod.

image.png

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
使用NAT网关轻松为单台云服务器设置多个公网IP
在应用中,有时会遇到用户询问如何使单台云服务器具备多个公网IP的问题。 具体如何操作呢,有了NAT网关这个也不是难题。
26746 0
阿里云服务器怎么设置密码?怎么停机?怎么重启服务器?
如果在创建实例时没有设置密码,或者密码丢失,您可以在控制台上重新设置实例的登录密码。本文仅描述如何在 ECS 管理控制台上修改实例登录密码。
9529 0
阿里云服务器如何登录?阿里云服务器的三种登录方法
购买阿里云ECS云服务器后如何登录?场景不同,阿里云优惠总结大概有三种登录方式: 登录到ECS云服务器控制台 在ECS云服务器控制台用户可以更改密码、更换系.
13222 0
windows server 2008阿里云ECS服务器安全设置
最近我们Sinesafe安全公司在为客户使用阿里云ecs服务器做安全的过程中,发现服务器基础安全性都没有做。为了为站长们提供更加有效的安全基础解决方案,我们Sinesafe将对阿里云服务器win2008 系统进行基础安全部署实战过程! 比较重要的几部分 1.
9063 0
腾讯云服务器 设置ngxin + fastdfs +tomcat 开机自启动
在tomcat中新建一个可以启动的 .sh 脚本文件 /usr/local/tomcat7/bin/ export JAVA_HOME=/usr/local/java/jdk7 export PATH=$JAVA_HOME/bin/:$PATH export CLASSPATH=.
4623 0
阿里云服务器如何登录?阿里云服务器的三种登录方法
购买阿里云ECS云服务器后如何登录?场景不同,云吞铺子总结大概有三种登录方式: 登录到ECS云服务器控制台 在ECS云服务器控制台用户可以更改密码、更换系统盘、创建快照、配置安全组等操作如何登录ECS云服务器控制台? 1、先登录到阿里云ECS服务器控制台 2、点击顶部的“控制台” 3、通过左侧栏,切换到“云服务器ECS”即可,如下图所示 通过ECS控制台的远程连接来登录到云服务器 阿里云ECS云服务器自带远程连接功能,使用该功能可以登录到云服务器,简单且方便,如下图:点击“远程连接”,第一次连接会自动生成6位数字密码,输入密码即可登录到云服务器上。
21944 0
1853
文章
0
问答
来源圈子
更多
+ 订阅
文章排行榜
最热
最新
相关电子书
更多
《2021云上架构与运维峰会演讲合集》
立即下载
《零基础CSS入门教程》
立即下载
《零基础HTML入门教程》
立即下载