Sunday, September 1, 2013

Programetically Iterating through the rows in a VO

-> ViewRowImpl class represents a row corresponding to the EO for which the VO has been created.
-> RowSet class represents the queried rows.

If suppose we want to iterate through the rows of the employees of a particular department and give a hike of some amount :-

public void applyEmpRise(Number rise){
  // Initially get all the rows from the employees
   RowSet emp = (RowSet)getEmployeeVO();
   while(emp.hasNext()){
    // when there are any rows in the table
    // get the current row using the VORowImpl
     EmpVORowImpl currentRow = (EmpVORowImpl)emp.Next();
     currentRow.setSalary(currentRow.getSalary().add(rise));  
   }
}

No comments:

Post a Comment