在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");
}