OAF_开发系列29_实现OAF中批次处理迭代器RowSet/RowSetIterator(案例)

20150814 Created By BaoXinjianweb

1、摘要post


在Oracle官方指南和例子中,通常遍历记录,都是经过RowSetIterator的方式进行,RowSetIterator的用法,经过为VO建立一个迭代器来 循环每个行测试

但在实际应用也能够经过Row和Rowset的方式进行遍历记录spa

具体状况具体分析指针

 

1. 选中记录和记录集合的三种方式code

(1). 经过Row选中第一条记录:vo.getFirstFilteredRow("SelectFlag", new String("Y"));
orm

(2). 经过RowSet选中全部被选中的记录:vo.getFiterredRow("SelectFlag", new String("Y"));blog

(3). 经过RowSetIterator选中全部记录:vo.createRowSetIterator("selectIter");get

 

2、实施分析it


Step1. 建立CO中的方法

(1). vo.getFirstFilteredRow("SelectFlag", new String("Y"));

(2). vo.getFiterredRow("SelectFlag", new String("Y"));

(3). vo.createRowSetIterator("selectIter");

Step2. 在CO具体控制代码,分析三种选中方案

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { super.processFormRequest(pageContext, webBean); try { EmpManageAMImpl am = (EmpManageAMImpl)pageContext.getApplicationModule(webBean); EmployeesItaraterVOImpl vo = am.getEmployeesItaraterVO(); //方案1. 经过ROW获取第一个选中栏位 if ("select".equals(pageContext.getParameter(EVENT_PARAM))) { EmployeesItaraterVORowImpl row = (EmployeesItaraterVORowImpl) vo.getFirstFilteredRow("SelectFlag", new String("Y")); //获取记录集合 System.out.println("RowFirstEmployeeId=" + row.getEmployeeId()); } //方案2. 经过ROWSET获取全部选中栏位 if ("select".equals(pageContext.getParameter(EVENT_PARAM))) { Row[] rowset = vo.getFilteredRows("SelectFlag", new String("Y")); //获取记录集合 for (int i = 0; i < rowset.length; i++) { EmployeesItaraterVORowImpl row = (EmployeesItaraterVORowImpl)rowset[i]; //取得当前记录 System.out.println("RowsetEmployeeId=" + row.getEmployeeId()); } } //方案3. 经过RowSetIterator全部选中栏位 if ("select".equals(pageContext.getParameter(EVENT_PARAM))) { int rowcount = vo.getFetchedRowCount(); //取当前提取的记录集的记录数 RowSetIterator selectIter = vo.createRowSetIterator("selectIter"); //创建记录集的指示器 if (rowcount > 0) { selectIter.setRangeStart(0); //设置循环起点,至关于移动指针到第一条记录 selectIter.setRangeSize(rowcount); //设置循环次数 for (int i = 0; i < rowcount; i++) { EmployeesItaraterVORowImpl row = (EmployeesItaraterVORowImpl)selectIter.getRowAtRangeIndex(i); //取得当前记录 System.out.println("ItaraterEmployeeId=" + row.getEmployeeId()); } }
selectIter.closeRowSetIterator(); } } catch (Exception ex) { ex.printStackTrace(); } }

 

3、测试运行


Step1. 选中一条记录测试三种选中方式

Step2.  显示记录以下

Step3. 选中所有记录测试显示选中方式

Step4. 显示记录以下

 

Thanks and Regards

相关文章
相关标签/搜索