ADF修改默认filter查询将%改为%%方式

来源:互联网 发布:枸杞 怎么泡水 知乎 编辑:程序博客网 时间:2024/04/29 22:21
    public static void customQuery(QueryEvent queryEvent,String queryProcess){        FilterableQueryDescriptor queryDescriptor = (FilterableQueryDescriptor) queryEvent.getDescriptor();             ConjunctionCriterion cc = queryDescriptor.getFilterConjunctionCriterion();             List<Criterion> lc = cc.getCriterionList();             for(Criterion cr : lc){                AttributeDescriptor attr = ((AttributeCriterion) cr).getAttribute();                Object value = ((AttributeCriterion) cr).getValue();                if(attr.getType().equals(String.class)){                    if(value != null){                         ((AttributeCriterion) cr).setValue("%" + value + "%");                     }                    }            }            invokeEL(queryProcess,new Class[]{QueryEvent.class},new Object[]{queryEvent});            for(Criterion cr : lc){                AttributeDescriptor attr = ((AttributeCriterion) cr).getAttribute();                Object value = ((AttributeCriterion) cr).getValue();                if(attr.getType().equals(String.class)){                    if(value != null){                         ((AttributeCriterion) cr).setValue(value.toString().replace("%", ""));                     }                    }            }     }        public static Object invokeEL(String el, Class[] paramTypes,Object[] params){        FacesContext facesContext = FacesContext.getCurrentInstance();        ELContext eLContext = facesContext.getELContext();        ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();        MethodExpression exp = expressionFactory.createMethodExpression(eLContext, el, Object.class, paramTypes);        return exp.invoke(eLContext, params);    }

调用的地方为以下,比如通过一个按钮点击事件,其中queryProcess参数为table组件中queryListener属性的值,现在如今修改为以下自定义方式

    public void queryMyOrder(QueryEvent queryEvent) {                String queryProcess = "#{bindings.TPurchasedProductsView1Query.processQuery}";        ADFUtils.customQuery(queryEvent, queryProcess);            }


原创粉丝点击