Home » ADF » ADF: Undo Current Row Changes in table.
ADF: Undo Current Row Changes in table.

ADF: Undo Current Row Changes in table.

Today, I am going to share a very interesting tutorial. Sometimes user need to undo all changes performed in only selected table row and display the older values which exists in database.

So how to perform this task. If you are using “RollBack” operation, it reverts all changes performed in table. But if you want to keep all changes but undo the changes of  a single selected row. Then here is the solution. You have to get instance of current row and call “refresh” method.

Sample Code

For this tutorial I am using HR schema Employee table. Follow the steps below.

  1. Create Entity and View Object using Employee Table of HR Schema.
  2. Drag-Drop Employee View Object from Data Control as ADF table.
  3. Add One Extra Column for  “Undo Changes” Button.

    1

     

     

    2

     

  4. Write following lines of code in ActionListener method of “Undo Change”.
    public void undoChanges(ActionEvent actionEvent) {
           BindingContext bc=BindingContext.getCurrent();
           BindingContainer binding=bc.getCurrentBindingsEntry();
            DCBindingContainer bindingsImpl = (DCBindingContainer) binding;
            DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");
            ViewObject vo=dciter.getViewObject();
            Row row=vo.getCurrentRow();
            if(row!=null)
            {
                row.refresh(Row.REFRESH_UNDO_CHANGES|Row.REFRESH_WITH_DB_FORGET_CHANGES);
                
                }
            vo.executeQuery();
                               
        }
    
  5. 3

About Manish Pandey

Manish Pandey is a Senior Developer with more than 3 years of experience in JAVA Programming. Currently enhancing skills in ADF.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>