Monday, July 2, 2012

How to add a new row at the end of the ADF Table

I was reading through OTN Discussion Forums where I found one topic "How to add a new row at the end of the ADF Table", I found couple of articles which explains how to insert new rows to the end of ADF Table. Here is the list below.

Here is one more way to insert new rows to the end of ADF table by overriding the view object's(ViewImpl) insertRow() method.
/**
 * This method will overrides the view object's insertRow()
 * First create a new row
 * Removes the row from the collection and then retain it for insertion into another location.
 * Navigates to the last row in the row set.
 * Navigates to next row
 * Inserts the same row to the row set
 * @param row
 */
@Override
public void insertRow(Row row) {
 super.insertRow(row);
 row.removeAndRetain();
 last();
 next();
 getDefaultRowSet().insertRow(row);
}

You can download the sample workspace from here
[Runs with Oracle JDeveloper 11.1.2.0.0 (11g R2) + HR Schema]

Run the index.jspx page and navigate the departments records, now click on Create button. Notice in employee table new row is added to end of the ADF Table.

No comments:

Post a Comment