In Controller Code:
OAAdvancedTableBean tableBean =
(OAAdvancedTableBean)webBean.findChildRecursive("AdvTableId");
if (tableBean.getName().equals(pageContext.getParameter(SOURCE_PARAM)) &&
ADD_ROWS_EVENT.equals(pageContext.getParameter(EVENT_PARAM)))
{
String[] param ={ pageContext.getParameter(EVENT_PARAM), pageContext.getParameter("ProgrId") };
Serializable[] k ={ pageContext.getParameter("ProgrId"),ObjVerNum};
am.invokeMethod("repeatRowValidation", param);
am.invokeMethod("createRow", k);
}
Inside AM:
public void repeatRowValidation(String Event, String prgid)
{
OAViewObject VOMain = getSaleableAreaDtlsVO1();
System.out.println("Fetched vvvv Rowcount -->" +
VOMain.getFetchedRowCount());
int fetchedRowCount = VOMain.getFetchedRowCount();
if (fetchedRowCount >= 1)
{
intIter = intIter + 1;
strIter = "Iter" + intIter;
RowSetIterator iter = VOMain.createRowSetIterator(strIter);
for (int i = 1; i <= fetchedRowCount; i++)
{
SaleableAreaDtlsVORowImpl row = (SaleableAreaDtlsVORowImpl)iter.next();
if (row == null)
{
iter.closeRowSetIterator();
intIter = intIter + 1;
strIter = "Iter" + intIter;
throw new OAException("SaleableAreaDtlsVORow Doesnt Exist");
} else
{
System.out.println("type is -->" + row.getSaleableareaType());
if (row.getSaleableareaType() != null &&
!row.getSaleableareaType().equals("USR_DTLS"))
{
Row[] VOCommerRows =
VOMain.getFilteredRows("SaleableareaType", row.getSaleableareaType());
System.out.println("length -->" + VOCommerRows.length);
if (VOCommerRows.length > 1)
{
throw new OAException("The Type should be Unique..",
OAException.ERROR);
}
}
Row[] rows = VOMain.getFilteredRows("ProgramId", prgid);
Row Vorow = null;
if (rows != null && rows.length > 0)
{
if (Event != null && Event.equals("addRows"))
{
Vorow = rows[rows.length - 1];
if (Vorow.getAttribute("UnitsMeasure") == null)
{
throw new OAException("Units Should not be null..",
OAException.ERROR);
}
}
}
}
}iter.closeRowSetIterator();
}
}
public void createRow(String progid,String ObjVerNum)
{
OAViewObject pervo = getSaleableAreaDtlsVO1();
//if(!pervo.isPreparedForExecution()){ pervo.executeQuery(); }
pervo.setMaxFetchSize(0);
pervo.last(); // Go to the last Row of the VO
pervo.next();
Row row = pervo.createRow();
pervo.insertRow(row);
row.setNewRowState(Row.STATUS_INITIALIZED);
row.setAttribute("ProgramId", progid);
Number Sno = new Number(pervo.getFetchedRowCount());
row.setAttribute("SrNo", Sno);
row.setAttribute("ObjVerNum",new Number(Integer.parseInt(ObjVerNum)));
row.setAttribute("DeleteDisable", Boolean.FALSE);
}