ADF11g-026:ADF 11g:Disable没有数据的下拉列表

来源:互联网 发布:java简单源代码 编辑:程序博客网 时间:2024/05/16 07:31

介绍

由于功能比较简单,不做详细介绍,直接看下面代码。

关键代码

public class ListIsEmptyBean extends HashMap {        /**     * @param key el表达式,如#{binding.Departments},Departments一定是在     * pageDef文件中定义的List,或#{row.Departments}一定是VO中在某个字段上定义的下拉列表     * @return     */    @Override    public Object get(Object key) {        if(key == null) {            return false;        }        if(!(key instanceof String)) {            return false;        }        String el = (String)key;        if(!el.startsWith("#{")) {            throw new JboException("Error expression language : " + key);        }        //解析el表达式        Object value = JSFUtils.getExpressionValue(el);                if(value == null) {            return true;        }        if(value instanceof FacesCtrlListBinding) {            FacesCtrlListBinding listBinding = (FacesCtrlListBinding)value;            //用于判断下拉列表的第一项是否为null,或者其它没有意义的item            int nullValueIndex = listBinding.getNullValueIndex();            List list = listBinding.getItems();            if(nullValueIndex == -1) {                return list.isEmpty();                            } else {                return list.size() == 1;            }        } else {            throw new JboException("Error expression language : " + key + ", that is not list instance.");        }    }}

用法

1.将上面的类配置成Manage Bean,Scope为request,名称为listIsEmpty(自己随便取)

2.在下拉列表的disabled属性中添加如: #{listIsEmpty['#{binding.Departments}']}(在ADF中能给EL表达式直接传参的貌似还只能借助Map的get方法)。

原创粉丝点击