ADF 如何在客户端获取组件对象

由于ADF是JSF的扩展,在写JS代码的时候必然要调用组件对象,这里总结了三种方法:

(1).AdfUIComponent.findComponent(expr)

这种方式必须是具有实例化的组件后才能调用该方法,所有在客户端展现的ADF组件对象的类均是AdfUIComponent的子类,那么所有的ADF组件实例就都具有findComponent这个实例方法了。

以下是调用JS文件中的dbClickTable2函数,为要调用的组建添加一个clientListener:

<af:commandButton text="commandButton 2" id="btn2">

<af:clientListener method="dbClickTable2" type="action"/>

<af:serverListener type="dbClickServer"/>

</af:commandButton>

这是JS文件里的函数:

function dbClickTable2 (actionEvent){

var buttonComponent = actionEvent.getSource();

var output1 = buttonComponent.findComponent("Output1");

alert("output1 :"+output1);

}

其中通过actionEvent.getSource()活动组件对象,然后用findComponent调用组件,其中的参数为组建的ID,这样就可以使用了。

2. AdfPage.PAGE.findComponentByAbsoluteId

这种方法不需要实例化AdfUIComponent对象就可以轻松获取到页面的ADF组件对象引用。它能获取上下文的全局对象,当然得到的应该是已经实例化的ADF组件了。仍然以上面的代码为例,只是修改了JS文件中的代码:

function dbClickTable2 (actionEvent){

var output1 = AdfPage.PAGE.findComponentByAbsoluteId("Output1");

alert("output1 :"+output1);

}

其中无需使用actionEvent事件,用该种方法一步到位即可.

3.AdfPage.PAGE.findComponentByAbsoluteId(absolute expr)
该种方法类似于方法二,也是一步到位,具体的js代码为:

function dbClickTable2 (actionEvent){

var output1 = AdfPage.PAGE.findComponentByAbsoluteId ("Output1");

alert("output1 :"+output1);

}

转载于:https://my.oschina.net/u/560500/blog/67737

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值