Sunday, January 07, 2007

Bc4J:Clone a VO to another(with resultset)

public static void cloneTheVO(ViewObjectImpl vo){
String sViewDefname = vo.getDefFullName();

while(true){
ViewObjectImpl tempVO= (ViewObjectImpl)am.findViewObject("NewVOName");
if(tempVO == null) break;
else tempVO.remove();
}

ViewObjectImpl newVO = (ViewObjectImpl)am.createViewObject("NewVOName" , sViewDefname);
int iOrigRangeSize = vo.getRangeSize();
vo.setRangeSize(-1);
Row[] rows = vo.getAllRowsInRange();
vo.setRangeSize(iOrigRangeSize);

for(Row row : rows){//JDK5.0 feature..change it as required..
newVO.insertRow(row);
}

long lRows = newVO.getEstimatedRowCount();
System.out.println("lRows="+lRows);
}

No comments: