Saturday, November 21, 2009

11G : How to delete the row Progamatically in ADF ?

public String deleteDepartments() {
// Add event code here...
String seletedDept=JSFUtils.resolveExpression("#{bindings.DepartmentId.inputValue}").toString();
System.out.println("SeletedDepartment:: "+seletedDept);

String amDef = "model.queries.AppModule";
String config = "AppModuleLocal";
ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);
ViewObject deptVO=am.findViewObject("DepartmentsView1");
RowSetIterator DeptIter=deptVO.createRowSetIterator("DeptIter");
int rowcount= deptVO.getRowCount();
if(rowcount > 0)
{
DeptIter.setRangeStart(0);
DeptIter.setRangeSize(rowcount);
for (int i = rowcount-1; i >= 0 ; i--)
{
DepartmentsViewRowImpl depteRow = (DepartmentsViewRowImpl)DeptIter.getRowAtRangeIndex(i);
if(depteRow.getAttribute("DepartmentId").toString().equals(seletedDept)){
depteRow.remove();
}
}
}
}