ADF:给VO动态创建检索基准并获取程序需要的数据

来源:互联网 发布:淘宝怎么打印订单详情 编辑:程序博客网 时间:2024/05/21 00:00
  在ADF中,可以在程序中动态创建Where语句来过滤数据,也可以使用ViewCriteria来过滤需要的数据。

参考如下代码:

    public Long setHelpId(String usage){        ViewObjectImpl helpVO = this.getHelpTranslations();        //创建检索基准         ViewCriteria vc = helpVO.createViewCriteria();        ViewCriteriaRow vcr = vc.createViewCriteriaRow();        vcr.setAttribute("HelpUsage", "=" + usage);        vc.addElement(vcr);        //进行查询,并取得数据         RowIterator helpItr = helpVO.findByViewCriteria(vc, -1, ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES);        Row helpRow = helpItr.first();        return (Long)helpRow.getAttribute("HelpId");       }