adf学习:进度条的使用(progress bar demo)

本文介绍了如何在ADF中使用进度条组件显示数值比例,并根据比例自动调整颜色。通过view层传递最大值和当前值到back bean,根据比例设置进度条样式。当比例超过100%时,进度条显示为红色;否则显示为蓝色。内容涉及back bean的方法实现、自定义BoundedRangeModel以及相关API和参考资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景:使用进度条progress bar显示数值比例,比例超过100%时,progress bar显示为红色,否则为蓝色

view层传递两个参数到back bean中,这两个参数分别为最大值和当前值,我在这里使用progress bar组件显示这两个数值的比例关系:
<af:progressIndicator id=“pi1” 
     value="#{pageFlowScope.incidentRequestControl.rangeModel
(row.bindings.CurrentDuration.inputValue,row.bindings.MaxDuration.inputValue)}"
     styleClass="#{pageFlowScope.incidentRequestControl.progressBarStyleClass}"/>
back bean代码: 
//获取样式,事先定义好样式名称,参考How-to dynamically change the progress bar color according to its current value
    public String getProgressBarStyleClass(){
        if (precent>=100){
            progressBarStyleClass="red_progress_bar";
        }
        return progressBarStyleClass;
    }

//传入参数:当前值和最大值
    public MyProgressRangeModel rangeModel(String duration, String maxDuration) {
        MyProgressRangeModel rangeModel = new MyProgressRangeModel();
        if ((("".equals(maxDuration)) && (("".equals(duration)) && (duration != null) && (maxDuration != null)))) {
            rangeModel.setMaximum(Long.parseLong(maxDuration));
            rangeModel.setValue(Long.parseLong(duration));
        }
        return rangeModel;
    }

 //progress bar值的获取需要继承BoundedRangeModel抽象类,详见API文档
    private class MyProgressRangeModel extends BoundedRangeModel {
        long maxValue=0L;
        long currentValue=0L;
        @Override
        public long getMaximum() {
            // TODO Implement this method
            return maxValue;
        }

        @Override
        public long getValue() {
            // TODO Implement this method
            return currentValue;
        }
        public void setMaximum(long maxValue){
            this.maxValue=maxValue;
        }
        public void setValue(long currentValue){
            this.currentValue=currentValue;
        }
    }
final result:

参考文档:

API文档:
相关博客:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值