web dynpro for abap基础知识(三)

view controller也有自己的两个方法:

wddobeforeaction():
After the web dynpro application has been started and the user has raised a client event, the first methods to be processed in the wda are the wddobeforeaction() methods of all view controllers of the previous rendered view assembly, before the action handler method to the event processed.

webdomodifyview():
用于动态修改UI Element。

对于各类controller,用户都可以创建自己的methods。在创建method时,有三种类型可选:method, event handler和supply function。双击方法名就可以打开一个编辑器,书写实现代码。在一个component内,一个controller可以调用其他controller的方法,只要在这个controller内声明使用了另一个controller即可。如果要让一个controller的自定义方法能被位于component内的另外一个controller调用,那么需要设置该方法的Interface属性。

前面提到了controller的methods,现在轮到controller的attributes。除了interface controller和interface view controller外每个controller都有两个预定义好的attribute:WD_THIS和WD_CONTEXT。WD_THIS指向当前的controller interface, IF_<controller name>;WD_CONTEXT指向controller context下的root node。访问context内的其他node/attribute就是借助它来完成的。

如果一个controller声明使用component controller,那么一个标准attribute WD_COMP_CONTROLLER会被自动创建,以指向component controller,这样component controller内的methods和public attributes就能被调用,wd_comp-controller -> method name 。

如果一个controller A声明使用其他类型的controller B(不是component controller),这时在controller A中不会自动生成一个指向controller B的引用。为了得到指向B的引用需要下面的办法:

DATA: lo_ctrl TYPE REF TO ig_<ctrl>.
lo_ctrl = wd_this->get_<ctrl>_ctrl( ).

用户也可以自定义attribute。如果attribute的public flag被设置,那么这个attribute对于同一个component内的其他controller也是可见的。访问其他controller的public attribute的方式与访问method一样。

访问一个context node
对于每一个controller,系统都会为其自动创建一个interface,名为IF_<ctrol_name>。在这个interface中,对于每一个context node都会有一个相应的WDCTX_<node_name>存在。访问root node直接使用WD_CONTEXT,访问root node的子node使用get_child_node( )方法,要注意的是方法名作为参数被传递时必须是大写!方法返回指向指定node的引用,类型为IF_WD_CONTEXT_NODE。这个方法还有一个可选参数,是要访问的element在父node中的索引编号。

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值