ProgressIndicator组件使用指南之一:与Poll组件配合使用

187 篇文章 2 订阅
开发环境:JDeveloper 11.1.2.0.0。
说明:本文改自本人旧作,使用了目前最新的JDeveloper 11.1.2.0.0重新开发验证。(2011-8-4)

1. 页面代码
原理说明:
(1)Poll组件每隔interval(单位毫秒,-1表示停止)指定时间,调用pollListener方法一次。
(2)ProgressIndicator组件的partialTriggers指向Poll组件,这样pollListener每执行一次,ProgressIndicator组件就刷新一次。从视觉上看,就好像进度条在前进一样。
(3)Poll进度条组件必须使用viewScope的Managed Bean。
(4)注意ProgressIndicator组件的visible属性使用了EL动态设置。

<af:form id="f1">
<af:panelGroupLayout id="pgl1" layout="horizontal">
<af:commandButton text="Start Poll" id="cb1" partialSubmit="true"
actionListener="#{viewScope.myBackingBean.startButton_actionListener}"/>
<af:separator id="s1"/>
<af:commandButton text="Stop Poll" id="cb2" partialSubmit="true"
actionListener="#{viewScope.myBackingBean.stopButton_actionListener}"/>
</af:panelGroupLayout>
<af:poll id="pol1" interval="-1" pollListener="#{viewScope.myBackingBean.poll_listener}"
partialTriggers="cb1 cb2" binding="#{viewScope.myBackingBean.pollComponent}"/>
<af:progressIndicator id="pi1" partialTriggers="pol1"
value="#{viewScope.myBackingBean.myProgressRangeModel}" rendered="true"
visible="#{viewScope.myBackingBean.myProgressRangeModel.value > 0 and viewScope.myBackingBean.myProgressRangeModel.value <viewScope.myBackingBean.myProgressRangeModel.maximum }"/>
</af:form>

2. Managed Bean代码
public void poll_listener(PollEvent pollEvent) {
long value = myProgressRangeModel.getValue();
long count = value + stepPace;
if (count <= maxValue) {
myProgressRangeModel.setValue(count);
} else {
stopPoll();
}
}

public void startButton_actionListener(ActionEvent actionEvent) {
startPoll();
}

public void stopButton_actionListener(ActionEvent actionEvent) {
stopPoll();
}

public void startPoll() {
pollComponent.setInterval(1000);
AdfFacesContext.getCurrentInstance().addPartialTarget(pollComponent);
}

public void stopPoll() {
pollComponent.setInterval(-1);
AdfFacesContext.getCurrentInstance().addPartialTarget(pollComponent);
}

3. 运行页面


Project下载: MyProgressIndicator.7z

参考文献:
1. http://groundside.com/blog/DuncanMills.php?title=the_progress_indicator&more=1&c=1&tb=1&pb=1
2. http://gergerconsulting.blogspot.com/2007/04/adf-faces-progressindicator-example-for.html
3. http://www.gebs.ro/blog/oracle/adf-progress-indicator-in-fusion-middleware-11g/
4. http://jobinesh.blogspot.com/2010/08/example.html

5. http://hi.baidu.com/ganyu21/blog/item/a8baf31f07ac09f5e0fe0bbd.html

http://maping930883.blogspot.com/2011/08/adf104progressindicatorpoll.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值