Web Dynpro for ABAP(10):Handling Images and Web Icons
3.15Handling Images and Web Icons
使用class: CL_WD_WEB_ICON,处理网络图片;
支持的图片URL路径格式:
~IconAlias:示例:~Icon/Attachment、~IconLarge/AudioFile;
$NAME$ or $NAME$/path:SM59,Type:G,HTTP Connection to External Server;
/path:MIME Repository相对路径,示例:/sap/public/images/hello.gif;
image.ext or folder/image.ext:MIME当前WDA Component下img;
{/NAMESPACE/COMPONENT}/image.ext or {/NAMESPACE/COMPONENT}/folder/image.ext
通过Component访问其下MIME存储的img;
示例:
Component:WDR_TEST_WEB_ICONS,查看SAP提供Web Icons
Function: WDY_WB_VD_ICON_PICKER,查看Component中使用图片;
示例:
1.创建WDA: Z_TEST_WDA991;
2.创建VIEW:MAIN;
3.创建IMG1~IMGn;
4.设置IMG Source;
source1:~Icon/Airplane01
source2: ~IconLarge/AdaptationTechnical
source3: ~Pictogram/2DocsStar
source4: ICON_ABAP
source5: ~Workcenter/3People
source6: home.png
source7: {Z_TEST_WDA96}/trash.png
source8: MAIN.PAGE_INFO.IMG_SOURCE
其中source6是通过选择Component->右键->Create->Mime Object->Import上传图片;
其中source7是使用Component:Z_TEST_WDA96中已经Import上传图片;
其中source8:使用Context节点IMG_SOURCE的值;
5.实现WDDOINIT方法,设置节点IMG_SOURCE值;
示例:
DATA:lo_nd_page_info TYPE REF TO if_wd_context_node. DATA:lo_el_page_info TYPE REF TO if_wd_context_element. DATA:ls_page_info TYPE wd_this->Element_page_info. DATA:lv_img_source TYPE wd_this->Element_page_info-img_source. * navigate from <CONTEXT> to <PAGE_INFO> via lead selection lo_nd_page_info = wd_context->get_child_node( name = wd_this->wdctx_page_info ). * get element via lead selection lo_el_page_info = lo_nd_page_info->get_element( ). lv_img_source = 'https://img2.baidu.com/it/u=2943428014,2405024519&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'. * set single attribute lo_el_page_info->set_attribute( name = `IMG_SOURCE` value = lv_img_source ).
本文来自博客园,作者:渔歌晚唱,转载请注明原文链接:https://www.cnblogs.com/tangToms/p/16365467.html