How to refresh a table of data after inserting or deleting a row using ADF
Written by Lynn Munsinger, Oracle Corporation
This document explains how to refresh a table of data on a "browse" page after inserting a new row or deleting a row, when using a session bean data control. The image below depicts a browse page containing a table of departments, where buttons for inserting or deleting rows are available:
The user can select a row and click the Delete button. This button is bound to the removeEntity() data control method and by default, will immediately delete the row from the table in the database. However, the table will still display the row because the table is not refreshed by default. The section titled "Deleting a row using a session bean data control" explains how to refresh the table when a method such as removeEntity() is called and the user remains on the same page.
Another option in this scenario is to insert a new row. This is normally performed on a separate page. For example, the image below depicts an insert form where the user enters new data and clicks a submit button to insert the row:
The Create button on this page calls the persistEntity() data control method from the session bean. By default, the row will be immediately inserted into the table when this method is called. However, if the Create button also navigates the user back to the browse page, the table will not display the new row because it is not refreshed by default. The section titled, "Inserting a row using a session bean data control" explains how to refresh a table after a method such as persistEntity() is called and the user is returned to the page containing the table of data.
This document assumes that you have created a session bean which accesses either EJB Entity or TopLink POJO persistence objects, and that you have created a data control for the session bean. Additionally, the steps below assume that you have created a page containing a table of data, either using JSF, ADF Faces, or ADF Swing.
In the case of the browse page image above, the table was created by dragging the Departments collection from the data control palette onto the page and choosing Create > Tables > ADF Read Only Table... from the dynamic list.
In the insert page image, the insert form was created by dragging the Departments collection from beneath the Constructors node in the data control palette onto the page. This is just one way to create a new row, and the SRDemo sample and accompanying documentation explain how to perform insert operations using other methods.
The following image depicts the page flow for this scenario:
Deleting a row using a session bean data control
Add Delete functionality to the browse page
Perform the following steps to add delete functionality to the browse page:
Refresh the data table
Perform the following steps to refresh the table of data after deleting a row:
Inserting a row using a session bean data control
Add Create functionality to the insert page
Perform the following steps to use the constructor to create a new row:
Refresh the data table
Perform the following steps to refresh the table of data after inserting a row:
This document explains how to refresh a table of data on a browse page when using ADF and a session bean data control. The scenarios covered include:
The refresh operations for these scenarios are performed by using a JSF managed bean to execute a refresh, and by using the !adfFacesContext.postback refresh condition for an action called in the page definition file.
For further information, refer to the tutorials, sample applications, and ADF developer's guides on the JDeveloper page on Oracle Technology Network.