How to add new row to
table region in OAF
Now we are going to learn about how to add a new row
to table region.
Suppose we have a requirement that when we click on
add button it has to create a new row to enter the data.
Step 1:- Right click on table region select footer.
Step 2:- right click on table footer select new --
> addTableRow.
Write the below code in the processFormRequest of a controller
OAApplicationModule am = (OAApplicationModule)pageContext.getRootApplicationModule();
OAAdvancedTableBean tableBean =
(OAAdvancedTableBean)webBean.findIndexedChildRecursive("PdqSystemParametersEOVORN");
OATableFooterBean footerBean = (OATableFooterBean)tableBean.getFooter();
if(footerBean != null)
{
OAAddTableRowBean addTableRowBean =
(OAAddTableRowBean)footerBean.findIndexedChild("addTableRow1");
if(pageContext.getParameter("event") != null &&
"addRows".equals(pageContext.getParameter("event")))
{
am.createAnotherRow();
DBTransaction dbt = am.getDBTransaction();
dbt.commit();
}
}
Create one method called createAnotherRow() in am.
public
void createAnotherRow()
{
Row
row1 = null;
OAViewObject VO1 = null;
VO1 =
getPdqSystemParametersEOVO1();
row1 =
VO1.createRow();
VO1.setCurrentRow(VO1.last());
VO1.next();
VO1.insertRow(row1);
VO1.insertRow(row1);
row1.setNewRowState((byte)-1);
row1.setNewRowState((byte)-1);
}
Now run the page and see the output.
Now click on add button.
The new row has been created.